/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2005                    */
/* Created on:     25/04/2008 23:58:05                          */
/*==============================================================*/


if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('acesso') and o.name = 'fk_acesso_funcao__a_funcao')
alter table acesso
   drop constraint fk_acesso_funcao__a_funcao
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('acesso') and o.name = 'fk_acesso_perfil__a_perfil')
alter table acesso
   drop constraint fk_acesso_perfil__a_perfil
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('acesso') and o.name = 'fk_acesso_tipo_aces_tipo_ace')
alter table acesso
   drop constraint fk_acesso_tipo_aces_tipo_ace
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('anamnese') and o.name = 'fk_anamnese_animal__a_animal')
alter table anamnese
   drop constraint fk_anamnese_animal__a_animal
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('animal') and o.name = 'fk_animal_cliente___cliente')
alter table animal
   drop constraint fk_animal_cliente___cliente
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('animal') and o.name = 'fk_animal_pelagem___pelagem')
alter table animal
   drop constraint fk_animal_pelagem___pelagem
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('animal') and o.name = 'fk_animal_raca__ani_raca')
alter table animal
   drop constraint fk_animal_raca__ani_raca
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('animal_transportado') and o.name = 'fk_animal_t_animal__a_animal')
alter table animal_transportado
   drop constraint fk_animal_t_animal__a_animal
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('animal_transportado') and o.name = 'fk_animal_t_conducao__conducao')
alter table animal_transportado
   drop constraint fk_animal_t_conducao__conducao
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('animal_transportado') and o.name = 'fk_animal_t_itinerari_itinerar')
alter table animal_transportado
   drop constraint fk_animal_t_itinerari_itinerar
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('atendimento') and o.name = 'fk_atendime_animal__a_animal')
alter table atendimento
   drop constraint fk_atendime_animal__a_animal
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('atendimento') and o.name = 'fk_atendime_cliente___cliente')
alter table atendimento
   drop constraint fk_atendime_cliente___cliente
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('atendimento') and o.name = 'fk_atendime_funcionar_funciona')
alter table atendimento
   drop constraint fk_atendime_funcionar_funciona
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('atendimento') and o.name = 'fk_atendime_tipo_aten_tipo_ate')
alter table atendimento
   drop constraint fk_atendime_tipo_aten_tipo_ate
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('carteira_vacina') and o.name = 'fk_carteira_animal__c_animal')
alter table carteira_vacina
   drop constraint fk_carteira_animal__c_animal
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('carteira_vacina') and o.name = 'fk_carteira_vacina__c_vacina')
alter table carteira_vacina
   drop constraint fk_carteira_vacina__c_vacina
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('carteira_vermifugo') and o.name = 'fk_carteira_animal_ca_animal')
alter table carteira_vermifugo
   drop constraint fk_carteira_animal_ca_animal
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('carteira_vermifugo') and o.name = 'fk_carteira_vermifugo_vermifug')
alter table carteira_vermifugo
   drop constraint fk_carteira_vermifugo_vermifug
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('cheque_recebido') and o.name = 'fk_cheque_r_parcela_r_parcela_')
alter table cheque_recebido
   drop constraint fk_cheque_r_parcela_r_parcela_
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('cliente') and o.name = 'fk_cliente_atividade_atividad')
alter table cliente
   drop constraint fk_cliente_atividade_atividad
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('cliente') and o.name = 'fk_cliente_uf_local__uf')
alter table cliente
   drop constraint fk_cliente_uf_local__uf
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('cliente_endereco') and o.name = 'fk_cliente__cliente_c_cliente')
alter table cliente_endereco
   drop constraint fk_cliente__cliente_c_cliente
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('cliente_endereco') and o.name = 'fk_cliente__endereco__endereco')
alter table cliente_endereco
   drop constraint fk_cliente__endereco__endereco
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('cliente_telefone') and o.name = 'fk_cliente__cliente___cliente')
alter table cliente_telefone
   drop constraint fk_cliente__cliente___cliente
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('cliente_telefone') and o.name = 'fk_cliente__telefone__telefone')
alter table cliente_telefone
   drop constraint fk_cliente__telefone__telefone
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('compra') and o.name = 'fk_compra_fornecedo_forneced')
alter table compra
   drop constraint fk_compra_fornecedo_forneced
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('compra') and o.name = 'fk_compra_funcionar_funciona')
alter table compra
   drop constraint fk_compra_funcionar_funciona
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('compra') and o.name = 'fk_compra_natureza__natureza')
alter table compra
   drop constraint fk_compra_natureza__natureza
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('conducao') and o.name = 'fk_conducao_cliente___cliente')
alter table conducao
   drop constraint fk_conducao_cliente___cliente
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('conducao') and o.name = 'fk_conducao_funcionar_funciona')
alter table conducao
   drop constraint fk_conducao_funcionar_funciona
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('contas_pagar') and o.name = 'fk_contas_p_compra__c_compra')
alter table contas_pagar
   drop constraint fk_contas_p_compra__c_compra
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('contas_pagar') and o.name = 'fk_contas_p_conta_con_conta_co')
alter table contas_pagar
   drop constraint fk_contas_p_conta_con_conta_co
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('contas_pagar') and o.name = 'fk_contas_p_fornecedo_forneced')
alter table contas_pagar
   drop constraint fk_contas_p_fornecedo_forneced
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('contas_receber') and o.name = 'fk_contas_r_cliente___cliente')
alter table contas_receber
   drop constraint fk_contas_r_cliente___cliente
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('contas_receber') and o.name = 'fk_contas_r_conta_con_conta_co')
alter table contas_receber
   drop constraint fk_contas_r_conta_con_conta_co
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('contas_receber') and o.name = 'fk_contas_r_venda__co_venda')
alter table contas_receber
   drop constraint fk_contas_r_venda__co_venda
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('diaria_hospedagem') and o.name = 'fk_diaria_h_porte__di_porte')
alter table diaria_hospedagem
   drop constraint fk_diaria_h_porte__di_porte
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('empresa_endereco') and o.name = 'fk_empresa__empresa_endereco')
alter table empresa_endereco
   drop constraint fk_empresa__empresa_endereco
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('empresa_endereco') and o.name = 'fk_empresa__endereco__endereco')
alter table empresa_endereco
   drop constraint fk_empresa__endereco__endereco
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('empresa_telefone') and o.name = 'fk_empresa__empresa_e_empresa')
alter table empresa_telefone
   drop constraint fk_empresa__empresa_e_empresa
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('empresa_telefone') and o.name = 'fk_empresa__telefone__telefone')
alter table empresa_telefone
   drop constraint fk_empresa__telefone__telefone
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('endereco') and o.name = 'fk_endereco_tipo_ende_tipo_end')
alter table endereco
   drop constraint fk_endereco_tipo_ende_tipo_end
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('endereco') and o.name = 'fk_endereco_uf__ender_uf')
alter table endereco
   drop constraint fk_endereco_uf__ender_uf
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('exame_solicitado') and o.name = 'fk_exame_so_relations_animal')
alter table exame_solicitado
   drop constraint fk_exame_so_relations_animal
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('exame_solicitado') and o.name = 'fk_exame_so_relations_exame')
alter table exame_solicitado
   drop constraint fk_exame_so_relations_exame
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('fornecedor_endereco') and o.name = 'fk_forneced_endereco__endereco')
alter table fornecedor_endereco
   drop constraint fk_forneced_endereco__endereco
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('fornecedor_endereco') and o.name = 'fk_forneced_fornecedo_forneced')
alter table fornecedor_endereco
   drop constraint fk_forneced_fornecedo_forneced
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('fornecedor_telefone') and o.name = 'fk_forneced_fornecedo_telefone')
alter table fornecedor_telefone
   drop constraint fk_forneced_fornecedo_telefone
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('fornecedor_telefone') and o.name = 'fk_forneced_telefone__telefone')
alter table fornecedor_telefone
   drop constraint fk_forneced_telefone__telefone
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('funcionario') and o.name = 'fk_funciona_agenda__f_agenda')
alter table funcionario
   drop constraint fk_funciona_agenda__f_agenda
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('funcionario') and o.name = 'fk_funciona_atividade_atividad')
alter table funcionario
   drop constraint fk_funciona_atividade_atividad
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('funcionario') and o.name = 'fk_funciona_cargo__fu_cargo')
alter table funcionario
   drop constraint fk_funciona_cargo__fu_cargo
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('funcionario') and o.name = 'fk_funciona_uf_expedi_uf')
alter table funcionario
   drop constraint fk_funciona_uf_expedi_uf
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('funcionario') and o.name = 'fk_funciona_usuario___usuario')
alter table funcionario
   drop constraint fk_funciona_usuario___usuario
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('funcionario_endereco') and o.name = 'fk_funciona_endereco__endereco')
alter table funcionario_endereco
   drop constraint fk_funciona_endereco__endereco
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('funcionario_endereco') and o.name = 'fk_funciona_funcionar_end')
alter table funcionario_endereco
   drop constraint fk_funciona_funcionar_end
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('funcionario_telefone') and o.name = 'fk_funciona_funcionar_funciona')
alter table funcionario_telefone
   drop constraint fk_funciona_funcionar_funciona
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('funcionario_telefone') and o.name = 'fk_funciona_telefone_telefone')
alter table funcionario_telefone
   drop constraint fk_funciona_telefone_telefone
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('historico_senha') and o.name = 'fk_historic_usuario___usuario')
alter table historico_senha
   drop constraint fk_historic_usuario___usuario
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('hospedagem') and o.name = 'fk_hospedag_baia_hosp_baia')
alter table hospedagem
   drop constraint fk_hospedag_baia_hosp_baia
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('hospedagem') and o.name = 'fk_hospedag_cliente___cliente')
alter table hospedagem
   drop constraint fk_hospedag_cliente___cliente
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('hospedagem') and o.name = 'fk_hospedag_funcionar_funciona')
alter table hospedagem
   drop constraint fk_hospedag_funcionar_funciona
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('hospede') and o.name = 'fk_hospede_animal__h_animal')
alter table hospede
   drop constraint fk_hospede_animal__h_animal
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('hospede') and o.name = 'fk_hospede_diaria_ho_diaria_h')
alter table hospede
   drop constraint fk_hospede_diaria_ho_diaria_h
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('hospede') and o.name = 'fk_hospede_hospedage_hospedag')
alter table hospede
   drop constraint fk_hospede_hospedage_hospedag
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('item_compra') and o.name = 'fk_item_com_compra__i_compra')
alter table item_compra
   drop constraint fk_item_com_compra__i_compra
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('item_compra') and o.name = 'fk_item_com_produto___produto')
alter table item_compra
   drop constraint fk_item_com_produto___produto
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('item_produto_nd') and o.name = 'fk_item_pro_nota_desp_nota_des')
alter table item_produto_nd
   drop constraint fk_item_pro_nota_desp_nota_des
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('item_produto_nd') and o.name = 'fk_item_pro_produto___produto')
alter table item_produto_nd
   drop constraint fk_item_pro_produto___produto
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('item_produto_nf') and o.name = 'fk_item_pro_nota_fisc_nota_fis')
alter table item_produto_nf
   drop constraint fk_item_pro_nota_fisc_nota_fis
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('item_produto_nf') and o.name = 'fk_item_pro_relations_produto')
alter table item_produto_nf
   drop constraint fk_item_pro_relations_produto
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('item_servico_nd') and o.name = 'fk_item_ser_nota_desp_nota_des')
alter table item_servico_nd
   drop constraint fk_item_ser_nota_desp_nota_des
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('item_servico_nd') and o.name = 'fk_item_servico_nd___servico')
alter table item_servico_nd
   drop constraint fk_item_servico_nd___servico
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('item_servico_nf') and o.name = 'fk_item_ser_notafisca_nota_fis')
alter table item_servico_nf
   drop constraint fk_item_ser_notafisca_nota_fis
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('item_servico_nf') and o.name = 'fk_item_ser_servico___servico')
alter table item_servico_nf
   drop constraint fk_item_ser_servico___servico
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('lancamento_financeiro') and o.name = 'fk_lancamen_parcela_p_parcela_')
alter table lancamento_financeiro
   drop constraint fk_lancamen_parcela_p_parcela_
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('lancamento_financeiro') and o.name = 'fk_lancamen_parcela_r_parcela_')
alter table lancamento_financeiro
   drop constraint fk_lancamen_parcela_r_parcela_
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('nota_despesa') and o.name = 'fk_nota_des_atendimen_atendime')
alter table nota_despesa
   drop constraint fk_nota_des_atendimen_atendime
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('nota_despesa') and o.name = 'fk_nota_des_conducao__conducao')
alter table nota_despesa
   drop constraint fk_nota_des_conducao__conducao
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('nota_despesa') and o.name = 'fk_nota_des_hospedage_hospedag')
alter table nota_despesa
   drop constraint fk_nota_des_hospedage_hospedag
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('nota_fiscal') and o.name = 'fk_nota_fis_venda__no_venda')
alter table nota_fiscal
   drop constraint fk_nota_fis_venda__no_venda
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('ocorrencia_cheque') and o.name = 'fk_ocorrenc_cheque_re_cheque_r')
alter table ocorrencia_cheque
   drop constraint fk_ocorrenc_cheque_re_cheque_r
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('parcela_pagar') and o.name = 'fk_parcela__contas_pa_contas_p')
alter table parcela_pagar
   drop constraint fk_parcela__contas_pa_contas_p
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('parcela_pagar') and o.name = 'fk_parcela__cta_corre_conta_co')
alter table parcela_pagar
   drop constraint fk_parcela__cta_corre_conta_co
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('parcela_pagar') and o.name = 'fk_parcela__esp_pagam_especie_')
alter table parcela_pagar
   drop constraint fk_parcela__esp_pagam_especie_
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('parcela_receber') and o.name = 'fk_parcela__contas_re_contas_r')
alter table parcela_receber
   drop constraint fk_parcela__contas_re_contas_r
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('parcela_receber') and o.name = 'fk_parcela__conta_cor_conta_co')
alter table parcela_receber
   drop constraint fk_parcela__conta_cor_conta_co
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('parcela_receber') and o.name = 'fk_parcela__especie_p_especie_')
alter table parcela_receber
   drop constraint fk_parcela__especie_p_especie_
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('pendencia') and o.name = 'fk_pendenci_animal__p_animal')
alter table pendencia
   drop constraint fk_pendenci_animal__p_animal
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('pertence') and o.name = 'fk_pertence_hospede___hospede')
alter table pertence
   drop constraint fk_pertence_hospede___hospede
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('pesagem') and o.name = 'fk_pesagem_animal__p_animal')
alter table pesagem
   drop constraint fk_pesagem_animal__p_animal
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('produto') and o.name = 'fk_produto_fornecedo_forneced')
alter table produto
   drop constraint fk_produto_fornecedo_forneced
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('produto') and o.name = 'fk_produto_grupo_pro_grupo_pr')
alter table produto
   drop constraint fk_produto_grupo_pro_grupo_pr
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('produto') and o.name = 'fk_produto_unidade_m_unidade_')
alter table produto
   drop constraint fk_produto_unidade_m_unidade_
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('raca') and o.name = 'fk_raca_especie___especie')
alter table raca
   drop constraint fk_raca_especie___especie
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('raca') and o.name = 'fk_raca_porte__ra_porte')
alter table raca
   drop constraint fk_raca_porte__ra_porte
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('receita') and o.name = 'fk_receita_animal__r_animal')
alter table receita
   drop constraint fk_receita_animal__r_animal
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('recomendacao') and o.name = 'fk_recomend_hosp__rec_hospede')
alter table recomendacao
   drop constraint fk_recomend_hosp__rec_hospede
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('servico') and o.name = 'fk_servico_unidade_m_unidade_')
alter table servico
   drop constraint fk_servico_unidade_m_unidade_
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('telefone') and o.name = 'fk_telefone_tipo_tele_tipo_tel')
alter table telefone
   drop constraint fk_telefone_tipo_tele_tipo_tel
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('usuario') and o.name = 'fk_usuario_perfil__u_perfil')
alter table usuario
   drop constraint fk_usuario_perfil__u_perfil
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('venda') and o.name = 'fk_venda_cliente___cliente')
alter table venda
   drop constraint fk_venda_cliente___cliente
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('venda') and o.name = 'fk_venda_funcionar_funciona')
alter table venda
   drop constraint fk_venda_funcionar_funciona
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('venda') and o.name = 'fk_venda_natureza__natureza')
alter table venda
   drop constraint fk_venda_natureza__natureza
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('venda') and o.name = 'fk_venda_nota_desp_nota_des')
alter table venda
   drop constraint fk_venda_nota_desp_nota_des
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('acesso')
            and   name  = 'tipo_acesso___acesso_fk'
            and   indid > 0
            and   indid < 255)
   drop index acesso.tipo_acesso___acesso_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('acesso')
            and   name  = 'funcao__acesso_fk'
            and   indid > 0
            and   indid < 255)
   drop index acesso.funcao__acesso_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('acesso')
            and   name  = 'perfil__acesso_fk'
            and   indid > 0
            and   indid < 255)
   drop index acesso.perfil__acesso_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('acesso')
            and   type = 'U')
   drop table acesso
go

if exists (select 1
            from  sysobjects
           where  id = object_id('agenda')
            and   type = 'U')
   drop table agenda
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('anamnese')
            and   name  = 'animal__anamnese_fk'
            and   indid > 0
            and   indid < 255)
   drop index anamnese.animal__anamnese_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('anamnese')
            and   type = 'U')
   drop table anamnese
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('animal')
            and   name  = 'pelagem__animal_fk'
            and   indid > 0
            and   indid < 255)
   drop index animal.pelagem__animal_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('animal')
            and   name  = 'raca__animal_fk'
            and   indid > 0
            and   indid < 255)
   drop index animal.raca__animal_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('animal')
            and   name  = 'cliente__animal_fk'
            and   indid > 0
            and   indid < 255)
   drop index animal.cliente__animal_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('animal')
            and   type = 'U')
   drop table animal
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('animal_transportado')
            and   name  = 'animal__animal_transportado_fk'
            and   indid > 0
            and   indid < 255)
   drop index animal_transportado.animal__animal_transportado_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('animal_transportado')
            and   name  = 'itinerario__animal_transportado_fk'
            and   indid > 0
            and   indid < 255)
   drop index animal_transportado.itinerario__animal_transportado_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('animal_transportado')
            and   name  = 'conducao__animal_transportado_fk'
            and   indid > 0
            and   indid < 255)
   drop index animal_transportado.conducao__animal_transportado_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('animal_transportado')
            and   type = 'U')
   drop table animal_transportado
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('atendimento')
            and   name  = 'cliente__atendimento_fk'
            and   indid > 0
            and   indid < 255)
   drop index atendimento.cliente__atendimento_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('atendimento')
            and   name  = 'tipo_atendimento___atendimento_fk'
            and   indid > 0
            and   indid < 255)
   drop index atendimento.tipo_atendimento___atendimento_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('atendimento')
            and   name  = 'funcionario__atendimento_fk'
            and   indid > 0
            and   indid < 255)
   drop index atendimento.funcionario__atendimento_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('atendimento')
            and   name  = 'animal__atendimento_fk'
            and   indid > 0
            and   indid < 255)
   drop index atendimento.animal__atendimento_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('atendimento')
            and   type = 'U')
   drop table atendimento
go

if exists (select 1
            from  sysobjects
           where  id = object_id('atividade_profissional')
            and   type = 'U')
   drop table atividade_profissional
go

if exists (select 1
            from  sysobjects
           where  id = object_id('baia')
            and   type = 'U')
   drop table baia
go

if exists (select 1
            from  sysobjects
           where  id = object_id('cargo')
            and   type = 'U')
   drop table cargo
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('carteira_vacina')
            and   name  = 'animal__carteira_vacina_fk'
            and   indid > 0
            and   indid < 255)
   drop index carteira_vacina.animal__carteira_vacina_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('carteira_vacina')
            and   name  = 'vacina__carteira_vacina_fk'
            and   indid > 0
            and   indid < 255)
   drop index carteira_vacina.vacina__carteira_vacina_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('carteira_vacina')
            and   type = 'U')
   drop table carteira_vacina
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('carteira_vermifugo')
            and   name  = 'animal_carteira_vermifugo_fk'
            and   indid > 0
            and   indid < 255)
   drop index carteira_vermifugo.animal_carteira_vermifugo_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('carteira_vermifugo')
            and   name  = 'vermifugo__carteira_vermifugo_fk'
            and   indid > 0
            and   indid < 255)
   drop index carteira_vermifugo.vermifugo__carteira_vermifugo_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('carteira_vermifugo')
            and   type = 'U')
   drop table carteira_vermifugo
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('cheque_recebido')
            and   name  = 'parcela_receber__cheque_recebido_fk'
            and   indid > 0
            and   indid < 255)
   drop index cheque_recebido.parcela_receber__cheque_recebido_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('cheque_recebido')
            and   type = 'U')
   drop table cheque_recebido
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('cliente')
            and   name  = 'uf_local_expedicao_rg_fk'
            and   indid > 0
            and   indid < 255)
   drop index cliente.uf_local_expedicao_rg_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('cliente')
            and   name  = 'atividade_profissional__cliente_fk'
            and   indid > 0
            and   indid < 255)
   drop index cliente.atividade_profissional__cliente_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('cliente')
            and   type = 'U')
   drop table cliente
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('cliente_endereco')
            and   name  = 'endereco__cliente_endereco_fk'
            and   indid > 0
            and   indid < 255)
   drop index cliente_endereco.endereco__cliente_endereco_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('cliente_endereco')
            and   name  = 'cliente__cliente_endereco_fk'
            and   indid > 0
            and   indid < 255)
   drop index cliente_endereco.cliente__cliente_endereco_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('cliente_endereco')
            and   type = 'U')
   drop table cliente_endereco
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('cliente_telefone')
            and   name  = 'cliente__cliente_telefone_fk'
            and   indid > 0
            and   indid < 255)
   drop index cliente_telefone.cliente__cliente_telefone_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('cliente_telefone')
            and   name  = 'telefone__cliente_telefone_fk'
            and   indid > 0
            and   indid < 255)
   drop index cliente_telefone.telefone__cliente_telefone_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('cliente_telefone')
            and   type = 'U')
   drop table cliente_telefone
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('compra')
            and   name  = 'funcionario__compra_fk'
            and   indid > 0
            and   indid < 255)
   drop index compra.funcionario__compra_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('compra')
            and   name  = 'fornecedor__compra_fk'
            and   indid > 0
            and   indid < 255)
   drop index compra.fornecedor__compra_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('compra')
            and   name  = 'natureza_operacao_compra_fk'
            and   indid > 0
            and   indid < 255)
   drop index compra.natureza_operacao_compra_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('compra')
            and   type = 'U')
   drop table compra
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('conducao')
            and   name  = 'funcionario__conducao_fk'
            and   indid > 0
            and   indid < 255)
   drop index conducao.funcionario__conducao_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('conducao')
            and   name  = 'cliente__conducao_fk'
            and   indid > 0
            and   indid < 255)
   drop index conducao.cliente__conducao_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('conducao')
            and   type = 'U')
   drop table conducao
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('contas_pagar')
            and   name  = 'fornecedor__contas_pagar_fk'
            and   indid > 0
            and   indid < 255)
   drop index contas_pagar.fornecedor__contas_pagar_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('contas_pagar')
            and   name  = 'compra__contas_pagar_fk'
            and   indid > 0
            and   indid < 255)
   drop index contas_pagar.compra__contas_pagar_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('contas_pagar')
            and   name  = 'conta_contabil__contas_pagar_fk'
            and   indid > 0
            and   indid < 255)
   drop index contas_pagar.conta_contabil__contas_pagar_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('contas_pagar')
            and   type = 'U')
   drop table contas_pagar
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('contas_receber')
            and   name  = 'conta_contabil___contas_receber_fk'
            and   indid > 0
            and   indid < 255)
   drop index contas_receber.conta_contabil___contas_receber_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('contas_receber')
            and   name  = 'cliente__contas_receber_fk'
            and   indid > 0
            and   indid < 255)
   drop index contas_receber.cliente__contas_receber_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('contas_receber')
            and   name  = 'venda__contas_receber_fk'
            and   indid > 0
            and   indid < 255)
   drop index contas_receber.venda__contas_receber_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('contas_receber')
            and   type = 'U')
   drop table contas_receber
go

if exists (select 1
            from  sysobjects
           where  id = object_id('conta_contabil')
            and   type = 'U')
   drop table conta_contabil
go

if exists (select 1
            from  sysobjects
           where  id = object_id('conta_corrente')
            and   type = 'U')
   drop table conta_corrente
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('diaria_hospedagem')
            and   name  = 'porte__diaria_hospedagem_fk'
            and   indid > 0
            and   indid < 255)
   drop index diaria_hospedagem.porte__diaria_hospedagem_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('diaria_hospedagem')
            and   type = 'U')
   drop table diaria_hospedagem
go

if exists (select 1
            from  sysobjects
           where  id = object_id('empresa')
            and   type = 'U')
   drop table empresa
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('empresa_endereco')
            and   name  = 'endereco_empresa_endereco_fk'
            and   indid > 0
            and   indid < 255)
   drop index empresa_endereco.endereco_empresa_endereco_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('empresa_endereco')
            and   name  = 'empresa__empresa_endereco_fk'
            and   indid > 0
            and   indid < 255)
   drop index empresa_endereco.empresa__empresa_endereco_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('empresa_endereco')
            and   type = 'U')
   drop table empresa_endereco
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('empresa_telefone')
            and   name  = 'empresa_empresa_telefone_fk'
            and   indid > 0
            and   indid < 255)
   drop index empresa_telefone.empresa_empresa_telefone_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('empresa_telefone')
            and   name  = 'telefone_empresa_telefone_fk'
            and   indid > 0
            and   indid < 255)
   drop index empresa_telefone.telefone_empresa_telefone_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('empresa_telefone')
            and   type = 'U')
   drop table empresa_telefone
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('endereco')
            and   name  = 'uf__endereco_fk'
            and   indid > 0
            and   indid < 255)
   drop index endereco.uf__endereco_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('endereco')
            and   name  = 'tipo_endereco__endereco_fk'
            and   indid > 0
            and   indid < 255)
   drop index endereco.tipo_endereco__endereco_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('endereco')
            and   type = 'U')
   drop table endereco
go

if exists (select 1
            from  sysobjects
           where  id = object_id('especie')
            and   type = 'U')
   drop table especie
go

if exists (select 1
            from  sysobjects
           where  id = object_id('especie_pagamento')
            and   type = 'U')
   drop table especie_pagamento
go

if exists (select 1
            from  sysobjects
           where  id = object_id('exame')
            and   type = 'U')
   drop table exame
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('exame_solicitado')
            and   name  = 'relationship_133_fk'
            and   indid > 0
            and   indid < 255)
   drop index exame_solicitado.relationship_133_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('exame_solicitado')
            and   name  = 'relationship_132_fk'
            and   indid > 0
            and   indid < 255)
   drop index exame_solicitado.relationship_132_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('exame_solicitado')
            and   type = 'U')
   drop table exame_solicitado
go

if exists (select 1
            from  sysobjects
           where  id = object_id('fornecedor')
            and   type = 'U')
   drop table fornecedor
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('fornecedor_endereco')
            and   name  = 'endereco_fornecedor_endereco_fk'
            and   indid > 0
            and   indid < 255)
   drop index fornecedor_endereco.endereco_fornecedor_endereco_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('fornecedor_endereco')
            and   name  = 'fornecedor_endereco_fk'
            and   indid > 0
            and   indid < 255)
   drop index fornecedor_endereco.fornecedor_endereco_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('fornecedor_endereco')
            and   type = 'U')
   drop table fornecedor_endereco
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('fornecedor_telefone')
            and   name  = 'fornecedor_telefone_fk'
            and   indid > 0
            and   indid < 255)
   drop index fornecedor_telefone.fornecedor_telefone_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('fornecedor_telefone')
            and   name  = 'telefone_fornecedor_telefone_fk'
            and   indid > 0
            and   indid < 255)
   drop index fornecedor_telefone.telefone_fornecedor_telefone_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('fornecedor_telefone')
            and   type = 'U')
   drop table fornecedor_telefone
go

if exists (select 1
            from  sysobjects
           where  id = object_id('funcao')
            and   type = 'U')
   drop table funcao
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('funcionario')
            and   name  = 'usuario__funcionario_fk'
            and   indid > 0
            and   indid < 255)
   drop index funcionario.usuario__funcionario_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('funcionario')
            and   name  = 'cargo__funcionario_fk'
            and   indid > 0
            and   indid < 255)
   drop index funcionario.cargo__funcionario_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('funcionario')
            and   name  = 'atividade_profissional__funcionario_fk'
            and   indid > 0
            and   indid < 255)
   drop index funcionario.atividade_profissional__funcionario_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('funcionario')
            and   name  = 'uf_expedicao_rg_funcionario_fk'
            and   indid > 0
            and   indid < 255)
   drop index funcionario.uf_expedicao_rg_funcionario_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('funcionario')
            and   name  = 'agenda__funcionario_fk'
            and   indid > 0
            and   indid < 255)
   drop index funcionario.agenda__funcionario_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('funcionario')
            and   type = 'U')
   drop table funcionario
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('funcionario_endereco')
            and   name  = 'endereco_funcionario_endereco_fk'
            and   indid > 0
            and   indid < 255)
   drop index funcionario_endereco.endereco_funcionario_endereco_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('funcionario_endereco')
            and   name  = 'funcionario_funcionario_endereco_fk'
            and   indid > 0
            and   indid < 255)
   drop index funcionario_endereco.funcionario_funcionario_endereco_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('funcionario_endereco')
            and   type = 'U')
   drop table funcionario_endereco
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('funcionario_telefone')
            and   name  = 'telefone_funcionario_telefone_fk'
            and   indid > 0
            and   indid < 255)
   drop index funcionario_telefone.telefone_funcionario_telefone_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('funcionario_telefone')
            and   name  = 'funcionario__funcionario_telefone_fk'
            and   indid > 0
            and   indid < 255)
   drop index funcionario_telefone.funcionario__funcionario_telefone_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('funcionario_telefone')
            and   type = 'U')
   drop table funcionario_telefone
go

if exists (select 1
            from  sysobjects
           where  id = object_id('grupo_produto')
            and   type = 'U')
   drop table grupo_produto
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('historico_senha')
            and   name  = 'usuario__historico_senha_fk'
            and   indid > 0
            and   indid < 255)
   drop index historico_senha.usuario__historico_senha_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('historico_senha')
            and   type = 'U')
   drop table historico_senha
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('hospedagem')
            and   name  = 'cliente__hospedagem_fk'
            and   indid > 0
            and   indid < 255)
   drop index hospedagem.cliente__hospedagem_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('hospedagem')
            and   name  = 'funcionario__hospedagem_fk'
            and   indid > 0
            and   indid < 255)
   drop index hospedagem.funcionario__hospedagem_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('hospedagem')
            and   name  = 'baia_hospedagem_fk'
            and   indid > 0
            and   indid < 255)
   drop index hospedagem.baia_hospedagem_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('hospedagem')
            and   type = 'U')
   drop table hospedagem
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('hospede')
            and   name  = 'animal__hospede_fk'
            and   indid > 0
            and   indid < 255)
   drop index hospede.animal__hospede_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('hospede')
            and   name  = 'diaria_hospedagem__hospede_fk'
            and   indid > 0
            and   indid < 255)
   drop index hospede.diaria_hospedagem__hospede_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('hospede')
            and   name  = 'hospedagem__hospede_fk'
            and   indid > 0
            and   indid < 255)
   drop index hospede.hospedagem__hospede_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('hospede')
            and   type = 'U')
   drop table hospede
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('item_compra')
            and   name  = 'compra__item_compra_fk'
            and   indid > 0
            and   indid < 255)
   drop index item_compra.compra__item_compra_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('item_compra')
            and   name  = 'produto__item_compra_fk'
            and   indid > 0
            and   indid < 255)
   drop index item_compra.produto__item_compra_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('item_compra')
            and   type = 'U')
   drop table item_compra
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('item_produto_nd')
            and   name  = 'nota_despesa__item_produto_nd_fk'
            and   indid > 0
            and   indid < 255)
   drop index item_produto_nd.nota_despesa__item_produto_nd_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('item_produto_nd')
            and   name  = 'produto__item_produto_nd_fk'
            and   indid > 0
            and   indid < 255)
   drop index item_produto_nd.produto__item_produto_nd_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('item_produto_nd')
            and   type = 'U')
   drop table item_produto_nd
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('item_produto_nf')
            and   name  = 'nota_fiscal__item_notafiscal_produto_fk'
            and   indid > 0
            and   indid < 255)
   drop index item_produto_nf.nota_fiscal__item_notafiscal_produto_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('item_produto_nf')
            and   type = 'U')
   drop table item_produto_nf
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('item_servico_nd')
            and   name  = 'servico__item_servico_nd_fk'
            and   indid > 0
            and   indid < 255)
   drop index item_servico_nd.servico__item_servico_nd_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('item_servico_nd')
            and   name  = 'nota_despesa__item_servico_nd_fk'
            and   indid > 0
            and   indid < 255)
   drop index item_servico_nd.nota_despesa__item_servico_nd_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('item_servico_nd')
            and   type = 'U')
   drop table item_servico_nd
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('item_servico_nf')
            and   name  = 'nota_fiscal__item_notafiscal_servico_fk'
            and   indid > 0
            and   indid < 255)
   drop index item_servico_nf.nota_fiscal__item_notafiscal_servico_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('item_servico_nf')
            and   type = 'U')
   drop table item_servico_nf
go

if exists (select 1
            from  sysobjects
           where  id = object_id('itinerario')
            and   type = 'U')
   drop table itinerario
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('lancamento_financeiro')
            and   name  = 'parcela_receber___movimento_diario_fk'
            and   indid > 0
            and   indid < 255)
   drop index lancamento_financeiro.parcela_receber___movimento_diario_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('lancamento_financeiro')
            and   name  = 'parcela_pagar__movimento_diario_fk'
            and   indid > 0
            and   indid < 255)
   drop index lancamento_financeiro.parcela_pagar__movimento_diario_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('lancamento_financeiro')
            and   type = 'U')
   drop table lancamento_financeiro
go

if exists (select 1
            from  sysobjects
           where  id = object_id('natureza_operacao')
            and   type = 'U')
   drop table natureza_operacao
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('nota_despesa')
            and   name  = 'atendimento_nota_despesa_fk'
            and   indid > 0
            and   indid < 255)
   drop index nota_despesa.atendimento_nota_despesa_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('nota_despesa')
            and   name  = 'hospedagem__nota_despesa_fk'
            and   indid > 0
            and   indid < 255)
   drop index nota_despesa.hospedagem__nota_despesa_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('nota_despesa')
            and   name  = 'conducao__nota_despesa_fk'
            and   indid > 0
            and   indid < 255)
   drop index nota_despesa.conducao__nota_despesa_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('nota_despesa')
            and   type = 'U')
   drop table nota_despesa
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('nota_fiscal')
            and   name  = 'venda__nota_fiscal_fk'
            and   indid > 0
            and   indid < 255)
   drop index nota_fiscal.venda__nota_fiscal_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('nota_fiscal')
            and   type = 'U')
   drop table nota_fiscal
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('ocorrencia_cheque')
            and   name  = 'cheque_recebido__ocorrencia_cheque_fk'
            and   indid > 0
            and   indid < 255)
   drop index ocorrencia_cheque.cheque_recebido__ocorrencia_cheque_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('ocorrencia_cheque')
            and   type = 'U')
   drop table ocorrencia_cheque
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('parcela_pagar')
            and   name  = 'cta_corrente__parcela_pagar_fk'
            and   indid > 0
            and   indid < 255)
   drop index parcela_pagar.cta_corrente__parcela_pagar_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('parcela_pagar')
            and   name  = 'esp_pagamento__parcela_pagar_fk'
            and   indid > 0
            and   indid < 255)
   drop index parcela_pagar.esp_pagamento__parcela_pagar_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('parcela_pagar')
            and   name  = 'contas_pagar__parcela_pagar_fk'
            and   indid > 0
            and   indid < 255)
   drop index parcela_pagar.contas_pagar__parcela_pagar_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('parcela_pagar')
            and   type = 'U')
   drop table parcela_pagar
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('parcela_receber')
            and   name  = 'especie_pagamento__parcela_receber_fk'
            and   indid > 0
            and   indid < 255)
   drop index parcela_receber.especie_pagamento__parcela_receber_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('parcela_receber')
            and   name  = 'conta_corrente__parcela_receber_fk'
            and   indid > 0
            and   indid < 255)
   drop index parcela_receber.conta_corrente__parcela_receber_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('parcela_receber')
            and   name  = 'contas_receber__parcela_receber_fk'
            and   indid > 0
            and   indid < 255)
   drop index parcela_receber.contas_receber__parcela_receber_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('parcela_receber')
            and   type = 'U')
   drop table parcela_receber
go

if exists (select 1
            from  sysobjects
           where  id = object_id('pelagem')
            and   type = 'U')
   drop table pelagem
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('pendencia')
            and   name  = 'animal__pendencia_fk'
            and   indid > 0
            and   indid < 255)
   drop index pendencia.animal__pendencia_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('pendencia')
            and   type = 'U')
   drop table pendencia
go

if exists (select 1
            from  sysobjects
           where  id = object_id('perfil')
            and   type = 'U')
   drop table perfil
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('pertence')
            and   name  = 'hospede__pertence_fk'
            and   indid > 0
            and   indid < 255)
   drop index pertence.hospede__pertence_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('pertence')
            and   type = 'U')
   drop table pertence
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('pesagem')
            and   name  = 'animal__pesagem_fk'
            and   indid > 0
            and   indid < 255)
   drop index pesagem.animal__pesagem_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('pesagem')
            and   type = 'U')
   drop table pesagem
go

if exists (select 1
            from  sysobjects
           where  id = object_id('porte')
            and   type = 'U')
   drop table porte
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('produto')
            and   name  = 'unidade_medida__produto_fk'
            and   indid > 0
            and   indid < 255)
   drop index produto.unidade_medida__produto_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('produto')
            and   name  = 'fornecedor_produto_fk'
            and   indid > 0
            and   indid < 255)
   drop index produto.fornecedor_produto_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('produto')
            and   name  = 'grupo_produto__produto_fk'
            and   indid > 0
            and   indid < 255)
   drop index produto.grupo_produto__produto_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('produto')
            and   type = 'U')
   drop table produto
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('raca')
            and   name  = 'porte__raca_fk'
            and   indid > 0
            and   indid < 255)
   drop index raca.porte__raca_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('raca')
            and   name  = 'especie__raca_fk'
            and   indid > 0
            and   indid < 255)
   drop index raca.especie__raca_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('raca')
            and   type = 'U')
   drop table raca
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('receita')
            and   name  = 'animal__receita_fk'
            and   indid > 0
            and   indid < 255)
   drop index receita.animal__receita_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('receita')
            and   type = 'U')
   drop table receita
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('recomendacao')
            and   name  = 'hosp__recomendacao_fk'
            and   indid > 0
            and   indid < 255)
   drop index recomendacao.hosp__recomendacao_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('recomendacao')
            and   type = 'U')
   drop table recomendacao
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('servico')
            and   name  = 'unidade_medida__servico_fk'
            and   indid > 0
            and   indid < 255)
   drop index servico.unidade_medida__servico_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('servico')
            and   type = 'U')
   drop table servico
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('telefone')
            and   name  = 'tipo_telefone__telefone_fk'
            and   indid > 0
            and   indid < 255)
   drop index telefone.tipo_telefone__telefone_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('telefone')
            and   type = 'U')
   drop table telefone
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tipo_acesso')
            and   type = 'U')
   drop table tipo_acesso
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tipo_atendimento')
            and   type = 'U')
   drop table tipo_atendimento
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tipo_endereco')
            and   type = 'U')
   drop table tipo_endereco
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tipo_telefone')
            and   type = 'U')
   drop table tipo_telefone
go

if exists (select 1
            from  sysobjects
           where  id = object_id('uf')
            and   type = 'U')
   drop table uf
go

if exists (select 1
            from  sysobjects
           where  id = object_id('unidade_medida')
            and   type = 'U')
   drop table unidade_medida
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('usuario')
            and   name  = 'perfil__usuario_fk'
            and   indid > 0
            and   indid < 255)
   drop index usuario.perfil__usuario_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('usuario')
            and   type = 'U')
   drop table usuario
go

if exists (select 1
            from  sysobjects
           where  id = object_id('vacina')
            and   type = 'U')
   drop table vacina
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('venda')
            and   name  = 'cliente__venda_fk'
            and   indid > 0
            and   indid < 255)
   drop index venda.cliente__venda_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('venda')
            and   name  = 'funcionario__venda_fk'
            and   indid > 0
            and   indid < 255)
   drop index venda.funcionario__venda_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('venda')
            and   name  = 'nota_despesa__venda_fk'
            and   indid > 0
            and   indid < 255)
   drop index venda.nota_despesa__venda_fk
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('venda')
            and   name  = 'natureza_operacao__venda_fk'
            and   indid > 0
            and   indid < 255)
   drop index venda.natureza_operacao__venda_fk
go

if exists (select 1
            from  sysobjects
           where  id = object_id('venda')
            and   type = 'U')
   drop table venda
go

if exists (select 1
            from  sysobjects
           where  id = object_id('vermifugo')
            and   type = 'U')
   drop table vermifugo
go

/*==============================================================*/
/* Table: acesso                                                */
/*==============================================================*/
create table acesso (
   cdacesso             int                  identity,
   cdperfil             int                  not null,
   cdfuncao             int                  not null,
   cdtipoacesso         int                  not null,
   dtatribuicaoacesso   datetime             null,
   ativo                bit                  null,
   constraint pk_acesso primary key nonclustered (cdacesso)
)
go

/*==============================================================*/
/* Index: perfil__acesso_fk                                     */
/*==============================================================*/
create index perfil__acesso_fk on acesso (
cdperfil asc
)
go

/*==============================================================*/
/* Index: funcao__acesso_fk                                     */
/*==============================================================*/
create index funcao__acesso_fk on acesso (
cdfuncao asc
)
go

/*==============================================================*/
/* Index: tipo_acesso___acesso_fk                               */
/*==============================================================*/
create index tipo_acesso___acesso_fk on acesso (
cdtipoacesso asc
)
go

/*==============================================================*/
/* Table: agenda                                                */
/*==============================================================*/
create table agenda (
   cdagenda             int                  identity,
   dsagenda             varchar(20)          null,
   horarioinicialdomingo datetime             null,
   horariofinaldomingo  datetime             null,
   horarioinicialsegunda datetime             null,
   horariofinalsegunda  datetime             null,
   horarioinicialterca  datetime             null,
   horariofinalterca    datetime             null,
   horarioinicialquarta datetime             null,
   horariofinalquarta   datetime             null,
   horarioinicialquinta datetime             null,
   horariofinalquinta   datetime             null,
   horarioinicialsexta  datetime             null,
   horariofinalsexta    datetime             null,
   horarioinicialsabado datetime             null,
   horariofinalsabado   datetime             null,
   intervaloagenda      smallint             null,
   ativo                bit                  null,
   constraint pk_agenda primary key nonclustered (cdagenda)
)
go

/*==============================================================*/
/* Table: anamnese                                              */
/*==============================================================*/
create table anamnese (
   nranamnese           int                  identity,
   cdanimal             int                  not null,
   dtanamnese           datetime             null,
   txanamnese           varchar(512)         null,
   ativo                bit                  null,
   constraint pk_anamnese primary key nonclustered (nranamnese)
)
go

/*==============================================================*/
/* Index: animal__anamnese_fk                                   */
/*==============================================================*/
create index animal__anamnese_fk on anamnese (
cdanimal asc
)
go

/*==============================================================*/
/* Table: animal                                                */
/*==============================================================*/
create table animal (
   cdanimal             int                  identity,
   cdcliente            int                  not null,
   cdpelagem            int                  null,
   cdraca               int                  not null,
   nmanimal             varchar(50)          null,
   sexo                 char(1)              null,
   dtnascimento         datetime             null,
   stpedigree           bit                  null,
   stfalecimento        bit                  null,
   ativo                bit                  null,
   versao               int                  null,
   constraint pk_animal primary key nonclustered (cdanimal)
)
go

/*==============================================================*/
/* Index: cliente__animal_fk                                    */
/*==============================================================*/
create index cliente__animal_fk on animal (
cdcliente asc
)
go

/*==============================================================*/
/* Index: raca__animal_fk                                       */
/*==============================================================*/
create index raca__animal_fk on animal (
cdraca asc
)
go

/*==============================================================*/
/* Index: pelagem__animal_fk                                    */
/*==============================================================*/
create index pelagem__animal_fk on animal (
cdpelagem asc
)
go

/*==============================================================*/
/* Table: animal_transportado                                   */
/*==============================================================*/
create table animal_transportado (
   cdanimaltransp       int                  identity,
   cdconducao           int                  not null,
   cdanimal             int                  not null,
   cditinerario         int                  not null,
   vlrunitanimal        money                null,
   constraint pk_animal_transportado primary key (cdanimaltransp)
)
go

/*==============================================================*/
/* Index: conducao__animal_transportado_fk                      */
/*==============================================================*/
create index conducao__animal_transportado_fk on animal_transportado (
cdconducao asc
)
go

/*==============================================================*/
/* Index: itinerario__animal_transportado_fk                    */
/*==============================================================*/
create index itinerario__animal_transportado_fk on animal_transportado (
cditinerario asc
)
go

/*==============================================================*/
/* Index: animal__animal_transportado_fk                        */
/*==============================================================*/
create index animal__animal_transportado_fk on animal_transportado (
cdanimal asc
)
go

/*==============================================================*/
/* Table: atendimento                                           */
/*==============================================================*/
create table atendimento (
   cdatendimento        int                  identity,
   cdtipoatdmto         int                  not null,
   cdcliente            int                  not null,
   cdanimal             int                  not null,
   cdfuncionario        int                  not null,
   dthragendamento      datetime             null,
   dthratendimento      datetime             null,
   txobservacao         varchar(60)          null,
   statendimento        char(1)              null,
   versao               int                  null,
   ativo                bit                  null,
   constraint pk_atendimento primary key nonclustered (cdatendimento)
)
go

/*==============================================================*/
/* Index: animal__atendimento_fk                                */
/*==============================================================*/
create index animal__atendimento_fk on atendimento (
cdanimal asc
)
go

/*==============================================================*/
/* Index: funcionario__atendimento_fk                           */
/*==============================================================*/
create index funcionario__atendimento_fk on atendimento (
cdfuncionario asc
)
go

/*==============================================================*/
/* Index: tipo_atendimento___atendimento_fk                     */
/*==============================================================*/
create index tipo_atendimento___atendimento_fk on atendimento (
cdtipoatdmto asc
)
go

/*==============================================================*/
/* Index: cliente__atendimento_fk                               */
/*==============================================================*/
create index cliente__atendimento_fk on atendimento (
cdcliente asc
)
go

/*==============================================================*/
/* Table: atividade_profissional                                */
/*==============================================================*/
create table atividade_profissional (
   cdativprofissional   int                  identity,
   dsativprofissional   varchar(40)          null,
   ativo                bit                  null,
   constraint pk_atividade_profissional primary key nonclustered (cdativprofissional)
)
go

/*==============================================================*/
/* Table: baia                                                  */
/*==============================================================*/
create table baia (
   cdbaia               int                  identity,
   dsbaia               varchar(30)          null,
   capacidade           smallint             null,
   ativo                bit                  null,
   constraint pk_baia primary key nonclustered (cdbaia)
)
go

/*==============================================================*/
/* Table: cargo                                                 */
/*==============================================================*/
create table cargo (
   cdcargo              int                  identity,
   dscargo              varchar(40)          null,
   ativo                bit                  null,
   constraint pk_cargo primary key nonclustered (cdcargo)
)
go

/*==============================================================*/
/* Table: carteira_vacina                                       */
/*==============================================================*/
create table carteira_vacina (
   nrvacinacao          int                  identity,
   cdanimal             int                  not null,
   cdvacina             int                  not null,
   dtvacinacao          datetime             null,
   dtproxvacinacao      datetime             null,
   stvacinacao          char(1)              null,
   txvacinacao          varchar(256)         null,
   constraint pk_carteira_vacina primary key (nrvacinacao)
)
go

/*==============================================================*/
/* Index: vacina__carteira_vacina_fk                            */
/*==============================================================*/
create index vacina__carteira_vacina_fk on carteira_vacina (
cdvacina asc
)
go

/*==============================================================*/
/* Index: animal__carteira_vacina_fk                            */
/*==============================================================*/
create index animal__carteira_vacina_fk on carteira_vacina (
cdanimal asc
)
go

/*==============================================================*/
/* Table: carteira_vermifugo                                    */
/*==============================================================*/
create table carteira_vermifugo (
   nrvermifugacao       int                  identity,
   cdanimal             int                  not null,
   cdvermifugo          int                  not null,
   dtvermifugacao       datetime             null,
   dtproxvermifugacao   datetime             null,
   stvermifugacao       char(1)              null,
   txvermifugacao       varchar(256)         null,
   constraint pk_carteira_vermifugo primary key (nrvermifugacao)
)
go

/*==============================================================*/
/* Index: vermifugo__carteira_vermifugo_fk                      */
/*==============================================================*/
create index vermifugo__carteira_vermifugo_fk on carteira_vermifugo (
cdvermifugo asc
)
go

/*==============================================================*/
/* Index: animal_carteira_vermifugo_fk                          */
/*==============================================================*/
create index animal_carteira_vermifugo_fk on carteira_vermifugo (
cdanimal asc
)
go

/*==============================================================*/
/* Table: cheque_recebido                                       */
/*==============================================================*/
create table cheque_recebido (
   cdchequerecebido     int                  identity,
   cdparcelareceber     int                  not null,
   cdbanco              int                  not null,
   nragencia            int                  not null,
   nrcheque             int                  not null,
   compensado           bit                  null,
   ativo                bit                  null,
   constraint pk_cheque_recebido primary key nonclustered (cdchequerecebido)
)
go

/*==============================================================*/
/* Index: parcela_receber__cheque_recebido_fk                   */
/*==============================================================*/
create index parcela_receber__cheque_recebido_fk on cheque_recebido (
cdparcelareceber asc
)
go

/*==============================================================*/
/* Table: cliente                                               */
/*==============================================================*/
create table cliente (
   cdcliente            int                  identity,
   cdativprofissional   int                  not null,
   cduf                 smallint             not null,
   nmcliente            varchar(60)          null,
   dtcadastro           datetime             null,
   dtnascimento         datetime             null,
   sexo                 char(1)              null,
   tpcliente            char(1)              null,
   qualificacao         char(1)              null,
   email                varchar(60)          null,
   site                 varchar(60)          null,
   cpf                  varchar(11)          null,
   rg                   varchar(10)          null,
   orgaoexpedidor       varchar(40)          null,
   ativo                bit                  null,
   constraint pk_cliente primary key nonclustered (cdcliente)
)
go

/*==============================================================*/
/* Index: atividade_profissional__cliente_fk                    */
/*==============================================================*/
create index atividade_profissional__cliente_fk on cliente (
cdativprofissional asc
)
go

/*==============================================================*/
/* Index: uf_local_expedicao_rg_fk                              */
/*==============================================================*/
create index uf_local_expedicao_rg_fk on cliente (
cduf asc
)
go

/*==============================================================*/
/* Table: cliente_endereco                                      */
/*==============================================================*/
create table cliente_endereco (
   cdcliente            int                  not null,
   cdendereco           int                  not null,
   constraint pk_cliente_endereco primary key (cdcliente, cdendereco)
)
go

/*==============================================================*/
/* Index: cliente__cliente_endereco_fk                          */
/*==============================================================*/
create index cliente__cliente_endereco_fk on cliente_endereco (
cdcliente asc
)
go

/*==============================================================*/
/* Index: endereco__cliente_endereco_fk                         */
/*==============================================================*/
create index endereco__cliente_endereco_fk on cliente_endereco (
cdendereco asc
)
go

/*==============================================================*/
/* Table: cliente_telefone                                      */
/*==============================================================*/
create table cliente_telefone (
   cdtelefone           int                  not null,
   cdcliente            int                  not null,
   constraint pk_cliente_telefone primary key (cdtelefone, cdcliente)
)
go

/*==============================================================*/
/* Index: telefone__cliente_telefone_fk                         */
/*==============================================================*/
create index telefone__cliente_telefone_fk on cliente_telefone (
cdtelefone asc
)
go

/*==============================================================*/
/* Index: cliente__cliente_telefone_fk                          */
/*==============================================================*/
create index cliente__cliente_telefone_fk on cliente_telefone (
cdcliente asc
)
go

/*==============================================================*/
/* Table: compra                                                */
/*==============================================================*/
create table compra (
   cdcompra             int                  identity,
   cdnatoperacao        int                  not null,
   cdfornecedor         int                  not null,
   cdfuncionario        int                  not null,
   dtcompra             datetime             null,
   vlrtotcompra         money                null,
   vlrbaseicmscompra    money                null,
   vricmscompra         money                null,
   nrfaturacompra       int                  null,
   vlrdescompra         money                null,
   txobservacao         varchar(60)          null,
   modopgto             char(1)              null,
   ativo                bit                  null,
   constraint pk_compra primary key nonclustered (cdcompra)
)
go

/*==============================================================*/
/* Index: natureza_operacao_compra_fk                           */
/*==============================================================*/
create index natureza_operacao_compra_fk on compra (
cdnatoperacao asc
)
go

/*==============================================================*/
/* Index: fornecedor__compra_fk                                 */
/*==============================================================*/
create index fornecedor__compra_fk on compra (
cdfornecedor asc
)
go

/*==============================================================*/
/* Index: funcionario__compra_fk                                */
/*==============================================================*/
create index funcionario__compra_fk on compra (
cdfuncionario asc
)
go

/*==============================================================*/
/* Table: conducao                                              */
/*==============================================================*/
create table conducao (
   cdconducao           int                  identity,
   cdcliente            int                  not null,
   cdfuncionario        int                  not null,
   dtconducao           datetime             null,
   vlrtotconducao       money                null,
   ativo                bit                  null,
   constraint pk_conducao primary key nonclustered (cdconducao)
)
go

/*==============================================================*/
/* Index: cliente__conducao_fk                                  */
/*==============================================================*/
create index cliente__conducao_fk on conducao (
cdcliente asc
)
go

/*==============================================================*/
/* Index: funcionario__conducao_fk                              */
/*==============================================================*/
create index funcionario__conducao_fk on conducao (
cdfuncionario asc
)
go

/*==============================================================*/
/* Table: contas_pagar                                          */
/*==============================================================*/
create table contas_pagar (
   cdcontapagar         int                  identity,
   cdcompra             int                  not null,
   cdfornecedor         int                  not null,
   cdcontacontabil      int                  not null,
   dtemissaoctapagar    datetime             null,
   vrtotfinanceiro      money                null,
   stcontapagar         char(1)              null,
   ativo                bit                  null,
   constraint pk_contas_pagar primary key nonclustered (cdcontapagar)
)
go

/*==============================================================*/
/* Index: conta_contabil__contas_pagar_fk                       */
/*==============================================================*/
create index conta_contabil__contas_pagar_fk on contas_pagar (
cdcontacontabil asc
)
go

/*==============================================================*/
/* Index: compra__contas_pagar_fk                               */
/*==============================================================*/
create index compra__contas_pagar_fk on contas_pagar (
cdcompra asc
)
go

/*==============================================================*/
/* Index: fornecedor__contas_pagar_fk                           */
/*==============================================================*/
create index fornecedor__contas_pagar_fk on contas_pagar (
cdfornecedor asc
)
go

/*==============================================================*/
/* Table: contas_receber                                        */
/*==============================================================*/
create table contas_receber (
   cdcontareceber       int                  identity,
   cdvenda              int                  not null,
   cdcliente            int                  not null,
   cdcontacontabil      int                  not null,
   dtemissaoctareceber  datetime             null,
   vlrtotctareceber     money                null,
   stcontareceber       char(1)              null,
   ativo                bit                  null,
   constraint pk_contas_receber primary key nonclustered (cdcontareceber)
)
go

/*==============================================================*/
/* Index: venda__contas_receber_fk                              */
/*==============================================================*/
create index venda__contas_receber_fk on contas_receber (
cdvenda asc
)
go

/*==============================================================*/
/* Index: cliente__contas_receber_fk                            */
/*==============================================================*/
create index cliente__contas_receber_fk on contas_receber (
cdcliente asc
)
go

/*==============================================================*/
/* Index: conta_contabil___contas_receber_fk                    */
/*==============================================================*/
create index conta_contabil___contas_receber_fk on contas_receber (
cdcontacontabil asc
)
go

/*==============================================================*/
/* Table: conta_contabil                                        */
/*==============================================================*/
create table conta_contabil (
   cdcontacontabil      int                  identity,
   dscontacontabil      varchar(40)          null,
   tpcontacontabil      char(1)              null,
   indlancamento        char(1)              null,
   ativo                bit                  null,
   constraint pk_conta_contabil primary key nonclustered (cdcontacontabil)
)
go

/*==============================================================*/
/* Table: conta_corrente                                        */
/*==============================================================*/
create table conta_corrente (
   cdcontacorrente      int                  identity,
   dscontacorrente      varchar(20)          null,
   txobservacao         varchar(60)          null,
   ativo                bit                  null,
   constraint pk_conta_corrente primary key nonclustered (cdcontacorrente)
)
go

/*==============================================================*/
/* Table: diaria_hospedagem                                     */
/*==============================================================*/
create table diaria_hospedagem (
   cddiariahosp         int                  identity,
   cdporte              int                  not null,
   vlrdiariahosp        money                null,
   ativo                bit                  null,
   constraint pk_diaria_hospedagem primary key nonclustered (cddiariahosp)
)
go

/*==============================================================*/
/* Index: porte__diaria_hospedagem_fk                           */
/*==============================================================*/
create index porte__diaria_hospedagem_fk on diaria_hospedagem (
cdporte asc
)
go

/*==============================================================*/
/* Table: empresa                                               */
/*==============================================================*/
create table empresa (
   cdempresa            int                  identity,
   nmfantasia           varchar(40)          null,
   nmrazaosocial        varchar(60)          null,
   cnpj                 varchar(14)          null,
   ie                   varchar(15)          null,
   email                varchar(60)          null,
   site                 varchar(60)          null,
   msgsaidaproduto      varchar(60)          null,
   termohospedagem      varchar(512)         null,
   imprimenf            bit                  null,
   imprimeboleto        bit                  null,
   integractarcber      bit                  null,
   integractapgar       bit                  null,
   permiteestoqueneg    bit                  null,
   permiteestoquemin    bit                  null,
   atualizacustoprod    bit                  null,
   geralancamento       bit                  null,
   qtddiasexpsenha      smallint             null,
   senhapadrao          varchar(50)          null,
   ativo                bit                  null,
   constraint pk_empresa primary key nonclustered (cdempresa)
)
go

/*==============================================================*/
/* Table: empresa_endereco                                      */
/*==============================================================*/
create table empresa_endereco (
   cdempresa            int                  not null,
   cdendereco           int                  not null,
   constraint pk_empresa_endereco primary key (cdempresa, cdendereco)
)
go

/*==============================================================*/
/* Index: empresa__empresa_endereco_fk                          */
/*==============================================================*/
create index empresa__empresa_endereco_fk on empresa_endereco (
cdempresa asc
)
go

/*==============================================================*/
/* Index: endereco_empresa_endereco_fk                          */
/*==============================================================*/
create index endereco_empresa_endereco_fk on empresa_endereco (
cdendereco asc
)
go

/*==============================================================*/
/* Table: empresa_telefone                                      */
/*==============================================================*/
create table empresa_telefone (
   cdtelefone           int                  not null,
   cdempresa            int                  not null,
   constraint pk_empresa_telefone primary key (cdtelefone, cdempresa)
)
go

/*==============================================================*/
/* Index: telefone_empresa_telefone_fk                          */
/*==============================================================*/
create index telefone_empresa_telefone_fk on empresa_telefone (
cdtelefone asc
)
go

/*==============================================================*/
/* Index: empresa_empresa_telefone_fk                           */
/*==============================================================*/
create index empresa_empresa_telefone_fk on empresa_telefone (
cdempresa asc
)
go

/*==============================================================*/
/* Table: endereco                                              */
/*==============================================================*/
create table endereco (
   cdendereco           int                  identity,
   cduf                 smallint             not null,
   cdtipoendereco       int                  not null,
   endereco             varchar(60)          null,
   complemento          varchar(30)          null,
   bairro               varchar(30)          null,
   cep                  varchar(8)           null,
   cidadeendereco       varchar(30)          null,
   ativo                bit                  null,
   constraint pk_endereco primary key nonclustered (cdendereco)
)
go

/*==============================================================*/
/* Index: tipo_endereco__endereco_fk                            */
/*==============================================================*/
create index tipo_endereco__endereco_fk on endereco (
cdtipoendereco asc
)
go

/*==============================================================*/
/* Index: uf__endereco_fk                                       */
/*==============================================================*/
create index uf__endereco_fk on endereco (
cduf asc
)
go

/*==============================================================*/
/* Table: especie                                               */
/*==============================================================*/
create table especie (
   cdespecie            int                  identity,
   nmespecie            varchar(30)          null,
   ativo                bit                  null,
   constraint pk_especie primary key nonclustered (cdespecie)
)
go

/*==============================================================*/
/* Table: especie_pagamento                                     */
/*==============================================================*/
create table especie_pagamento (
   cdesppagamento       int                  identity,
   dsesppagamento       varchar(30)          null,
   nrdiasvenc           smallint             null,
   prcjuros             money                null,
   ativo                bit                  null,
   constraint pk_especie_pagamento primary key nonclustered (cdesppagamento)
)
go

/*==============================================================*/
/* Table: exame                                                 */
/*==============================================================*/
create table exame (
   cdexame              int                  identity,
   dsexame              varchar(40)          null,
   ativo                bit                  null,
   constraint pk_exame primary key nonclustered (cdexame)
)
go

/*==============================================================*/
/* Table: exame_solicitado                                      */
/*==============================================================*/
create table exame_solicitado (
   nrsolicitacao        int                  identity,
   cdanimal             int                  not null,
   cdexame              int                  not null,
   dtsolicitacao        datetime             null,
   dtentrega            datetime             null,
   dsresultado          varchar(512)         null,
   ativo                bit                  null,
   constraint pk_exame_solicitado primary key (nrsolicitacao)
)
go

/*==============================================================*/
/* Index: relationship_132_fk                                   */
/*==============================================================*/
create index relationship_132_fk on exame_solicitado (
cdanimal asc
)
go

/*==============================================================*/
/* Index: relationship_133_fk                                   */
/*==============================================================*/
create index relationship_133_fk on exame_solicitado (
cdexame asc
)
go

/*==============================================================*/
/* Table: fornecedor                                            */
/*==============================================================*/
create table fornecedor (
   cdfornecedor         int                  identity,
   nmfantasia           varchar(40)          null,
   nmrazaosocial        varchar(60)          null,
   cnpj                 varchar(14)          null,
   ie                   varchar(15)          null,
   nmcontato            varchar(40)          null,
   cargocontato         varchar(30)          null,
   emailcontato         varchar(60)          null,
   dtcadastro           datetime             null,
   dtvisita             datetime             null,
   site                 varchar(60)          null,
   ativo                bit                  null,
   constraint pk_fornecedor primary key nonclustered (cdfornecedor)
)
go

/*==============================================================*/
/* Table: fornecedor_endereco                                   */
/*==============================================================*/
create table fornecedor_endereco (
   cdfornecedor         int                  not null,
   cdendereco           int                  not null,
   constraint pk_fornecedor_endereco primary key (cdfornecedor, cdendereco)
)
go

/*==============================================================*/
/* Index: fornecedor_endereco_fk                                */
/*==============================================================*/
create index fornecedor_endereco_fk on fornecedor_endereco (
cdfornecedor asc
)
go

/*==============================================================*/
/* Index: endereco_fornecedor_endereco_fk                       */
/*==============================================================*/
create index endereco_fornecedor_endereco_fk on fornecedor_endereco (
cdendereco asc
)
go

/*==============================================================*/
/* Table: fornecedor_telefone                                   */
/*==============================================================*/
create table fornecedor_telefone (
   cdtelefone           int                  not null,
   cdfornecedor         int                  not null,
   constraint pk_fornecedor_telefone primary key (cdtelefone, cdfornecedor)
)
go

/*==============================================================*/
/* Index: telefone_fornecedor_telefone_fk                       */
/*==============================================================*/
create index telefone_fornecedor_telefone_fk on fornecedor_telefone (
cdtelefone asc
)
go

/*==============================================================*/
/* Index: fornecedor_telefone_fk                                */
/*==============================================================*/
create index fornecedor_telefone_fk on fornecedor_telefone (
cdfornecedor asc
)
go

/*==============================================================*/
/* Table: funcao                                                */
/*==============================================================*/
create table funcao (
   cdfuncao             int                  identity,
   dsfuncao             varchar(40)          null,
   action               varchar(60)          null,
   ativo                bit                  null,
   constraint pk_funcao primary key nonclustered (cdfuncao)
)
go

/*==============================================================*/
/* Table: funcionario                                           */
/*==============================================================*/
create table funcionario (
   cdfuncionario        int                  identity,
   cdagenda             int                  null,
   cdusuario            int                  not null,
   cdcargo              int                  not null,
   cduf                 smallint             not null,
   cdativprofissional   int                  not null,
   nmfuncionario        varchar(60)          null,
   apelido              varchar(20)          null,
   rg                   varchar(10)          null,
   orgaoexpedidor       varchar(40)          null,
   cpf                  varchar(11)          null,
   cp                   varchar(10)          null,
   seriecp              varchar(6)           null,
   crm                  varchar(10)          null,
   dtnascimento         datetime             null,
   dtadmissao           datetime             null,
   dtdemissao           datetime             null,
   email                varchar(60)          null,
   prccomissao          money                null,
   prcdesconto          money                null,
   sexo                 char(1)              null,
   dtpagamento          datetime             null,
   vlrsalario           money                null,
   cargahoraria         smallint             null,
   custohora            money                null,
   custohoraextra       money                null,
   ativo                bit                  null,
   constraint pk_funcionario primary key nonclustered (cdfuncionario)
)
go

/*==============================================================*/
/* Index: agenda__funcionario_fk                                */
/*==============================================================*/
create index agenda__funcionario_fk on funcionario (
cdagenda asc
)
go

/*==============================================================*/
/* Index: uf_expedicao_rg_funcionario_fk                        */
/*==============================================================*/
create index uf_expedicao_rg_funcionario_fk on funcionario (
cduf asc
)
go

/*==============================================================*/
/* Index: atividade_profissional__funcionario_fk                */
/*==============================================================*/
create index atividade_profissional__funcionario_fk on funcionario (
cdativprofissional asc
)
go

/*==============================================================*/
/* Index: cargo__funcionario_fk                                 */
/*==============================================================*/
create index cargo__funcionario_fk on funcionario (
cdcargo asc
)
go

/*==============================================================*/
/* Index: usuario__funcionario_fk                               */
/*==============================================================*/
create index usuario__funcionario_fk on funcionario (
cdusuario asc
)
go

/*==============================================================*/
/* Table: funcionario_endereco                                  */
/*==============================================================*/
create table funcionario_endereco (
   cdfuncionario        int                  not null,
   cdendereco           int                  not null,
   constraint pk_funcionario_endereco primary key (cdfuncionario, cdendereco)
)
go

/*==============================================================*/
/* Index: funcionario_funcionario_endereco_fk                   */
/*==============================================================*/
create index funcionario_funcionario_endereco_fk on funcionario_endereco (
cdfuncionario asc
)
go

/*==============================================================*/
/* Index: endereco_funcionario_endereco_fk                      */
/*==============================================================*/
create index endereco_funcionario_endereco_fk on funcionario_endereco (
cdendereco asc
)
go

/*==============================================================*/
/* Table: funcionario_telefone                                  */
/*==============================================================*/
create table funcionario_telefone (
   cdfuncionario        int                  not null,
   cdtelefone           int                  not null,
   constraint pk_funcionario_telefone primary key (cdfuncionario, cdtelefone)
)
go

/*==============================================================*/
/* Index: funcionario__funcionario_telefone_fk                  */
/*==============================================================*/
create index funcionario__funcionario_telefone_fk on funcionario_telefone (
cdfuncionario asc
)
go

/*==============================================================*/
/* Index: telefone_funcionario_telefone_fk                      */
/*==============================================================*/
create index telefone_funcionario_telefone_fk on funcionario_telefone (
cdtelefone asc
)
go

/*==============================================================*/
/* Table: grupo_produto                                         */
/*==============================================================*/
create table grupo_produto (
   cdgrupoproduto       int                  identity,
   dsgrupoproduto       varchar(40)          null,
   ativo                bit                  null,
   constraint pk_grupo_produto primary key nonclustered (cdgrupoproduto)
)
go

/*==============================================================*/
/* Table: historico_senha                                       */
/*==============================================================*/
create table historico_senha (
   cdhistoricosenha     int                  identity,
   cdusuario            int                  not null,
   dtinchistorico       datetime             null,
   senhaanterior        varchar(50)          null,
   ativo                bit                  null,
   constraint pk_historico_senha primary key nonclustered (cdhistoricosenha)
)
go

/*==============================================================*/
/* Index: usuario__historico_senha_fk                           */
/*==============================================================*/
create index usuario__historico_senha_fk on historico_senha (
cdusuario asc
)
go

/*==============================================================*/
/* Table: hospedagem                                            */
/*==============================================================*/
create table hospedagem (
   cdhospedagem         int                  identity,
   cdbaia               int                  not null,
   cdfuncionario        int                  not null,
   cdcliente            int                  not null,
   dtinicio             datetime             null,
   dttermino            datetime             null,
   vlrtothospedagem     money                null,
   ativo                bit                  null,
   constraint pk_hospedagem primary key nonclustered (cdhospedagem)
)
go

/*==============================================================*/
/* Index: baia_hospedagem_fk                                    */
/*==============================================================*/
create index baia_hospedagem_fk on hospedagem (
cdbaia asc
)
go

/*==============================================================*/
/* Index: funcionario__hospedagem_fk                            */
/*==============================================================*/
create index funcionario__hospedagem_fk on hospedagem (
cdfuncionario asc
)
go

/*==============================================================*/
/* Index: cliente__hospedagem_fk                                */
/*==============================================================*/
create index cliente__hospedagem_fk on hospedagem (
cdcliente asc
)
go

/*==============================================================*/
/* Table: hospede                                               */
/*==============================================================*/
create table hospede (
   cdhospede            int                  identity,
   cdhospedagem         int                  not null,
   cdanimal             int                  not null,
   cddiariahosp         int                  not null,
   vlrdiaria            money                null,
   constraint pk_hospede primary key (cdhospede)
)
go

/*==============================================================*/
/* Index: hospedagem__hospede_fk                                */
/*==============================================================*/
create index hospedagem__hospede_fk on hospede (
cdhospedagem asc
)
go

/*==============================================================*/
/* Index: diaria_hospedagem__hospede_fk                         */
/*==============================================================*/
create index diaria_hospedagem__hospede_fk on hospede (
cddiariahosp asc
)
go

/*==============================================================*/
/* Index: animal__hospede_fk                                    */
/*==============================================================*/
create index animal__hospede_fk on hospede (
cdanimal asc
)
go

/*==============================================================*/
/* Table: item_compra                                           */
/*==============================================================*/
create table item_compra (
   cditemcompra         int                  identity,
   cdcompra             int                  not null,
   cdproduto            int                  not null,
   qtditemcompra        smallint             null,
   vlrunititemcompra    money                null,
   vlrtotitemcompra     money                null,
   constraint pk_item_compra primary key (cditemcompra)
)
go

/*==============================================================*/
/* Index: produto__item_compra_fk                               */
/*==============================================================*/
create index produto__item_compra_fk on item_compra (
cdproduto asc
)
go

/*==============================================================*/
/* Index: compra__item_compra_fk                                */
/*==============================================================*/
create index compra__item_compra_fk on item_compra (
cdcompra asc
)
go

/*==============================================================*/
/* Table: item_produto_nd                                       */
/*==============================================================*/
create table item_produto_nd (
   cditemprodnd         int                  identity,
   cdproduto            int                  not null,
   cdnotadespesa        int                  not null,
   qtditemprodnd        smallint             null,
   vlrunititemprodnd    money                null,
   vlrtotitemprodnd     money                null,
   vlrcomissao          money                null,
   prccomissao          money                null,
   vlrdesconto          money                null,
   prcdesconto          money                null,
   constraint pk_item_produto_nd primary key (cditemprodnd)
)
go

/*==============================================================*/
/* Index: produto__item_produto_nd_fk                           */
/*==============================================================*/
create index produto__item_produto_nd_fk on item_produto_nd (
cdproduto asc
)
go

/*==============================================================*/
/* Index: nota_despesa__item_produto_nd_fk                      */
/*==============================================================*/
create index nota_despesa__item_produto_nd_fk on item_produto_nd (
cdnotadespesa asc
)
go

/*==============================================================*/
/* Table: item_produto_nf                                       */
/*==============================================================*/
create table item_produto_nf (
   cditemprodutonf      int                  identity,
   nrnotafiscal         int                  not null,
   cdproduto            int                  not null,
   qtditemproduto       smallint             null,
   vlrunititemproduto   money                null,
   vlrtotitemproduto    money                null,
   prccomissao          money                null,
   vlrcomissao          money                null,
   prcdesconto          money                null,
   vlrdesconto          money                null,
   constraint pk_item_produto_nf primary key (cditemprodutonf)
)
go

/*==============================================================*/
/* Index: nota_fiscal__item_notafiscal_produto_fk               */
/*==============================================================*/
create index nota_fiscal__item_notafiscal_produto_fk on item_produto_nf (
nrnotafiscal asc
)
go

/*==============================================================*/
/* Table: item_servico_nd                                       */
/*==============================================================*/
create table item_servico_nd (
   cditemservicond      int                  identity,
   cdnotadespesa        int                  not null,
   cdservico            int                  not null,
   qtditemservicond     smallint             null,
   vlrunititemservicond money                null,
   vlrtotitemservicond  money                null,
   vlrcomissao          money                null,
   prccomissao          money                null,
   vlrdesconto          money                null,
   prcdesconto          money                null,
   constraint pk_item_servico_nd primary key (cditemservicond)
)
go

/*==============================================================*/
/* Index: nota_despesa__item_servico_nd_fk                      */
/*==============================================================*/
create index nota_despesa__item_servico_nd_fk on item_servico_nd (
cdnotadespesa asc
)
go

/*==============================================================*/
/* Index: servico__item_servico_nd_fk                           */
/*==============================================================*/
create index servico__item_servico_nd_fk on item_servico_nd (
cdservico asc
)
go

/*==============================================================*/
/* Table: item_servico_nf                                       */
/*==============================================================*/
create table item_servico_nf (
   cditemserviconf      int                  identity,
   nrnotafiscal         int                  not null,
   cdservico            int                  not null,
   qtditemservico       smallint             null,
   vlrunititemservico   money                null,
   vlrtotitemservico    money                null,
   prccomissao          money                null,
   vlrcomissao          money                null,
   prcdesconto          money                null,
   vlrdesconto          money                null,
   constraint pk_item_servico_nf primary key (cditemserviconf)
)
go

/*==============================================================*/
/* Index: nota_fiscal__item_notafiscal_servico_fk               */
/*==============================================================*/
create index nota_fiscal__item_notafiscal_servico_fk on item_servico_nf (
nrnotafiscal asc
)
go

/*==============================================================*/
/* Table: itinerario                                            */
/*==============================================================*/
create table itinerario (
   cditinerario         int                  identity,
   dsitinerario         varchar(60)          null,
   vlritinerario        money                null,
   ativo                bit                  null,
   constraint pk_itinerario primary key nonclustered (cditinerario)
)
go

/*==============================================================*/
/* Table: lancamento_financeiro                                 */
/*==============================================================*/
create table lancamento_financeiro (
   nrlancfinanc         int                  identity,
   cdparcelapagar       int                  null,
   cdparcelareceber     int                  null,
   dtlancfinanc         datetime             null,
   lanccaixa            bit                  null,
   lancfinanceiro       bit                  null,
   txhistlancfinanc     varchar(60)          null,
   vlrlancfinanc        money                null,
   indlancamento        char(1)              null,
   ativo                bit                  null,
   constraint pk_lancamento_financeiro primary key nonclustered (nrlancfinanc)
)
go

/*==============================================================*/
/* Index: parcela_pagar__movimento_diario_fk                    */
/*==============================================================*/
create index parcela_pagar__movimento_diario_fk on lancamento_financeiro (
cdparcelapagar asc
)
go

/*==============================================================*/
/* Index: parcela_receber___movimento_diario_fk                 */
/*==============================================================*/
create index parcela_receber___movimento_diario_fk on lancamento_financeiro (
cdparcelareceber asc
)
go

/*==============================================================*/
/* Table: natureza_operacao                                     */
/*==============================================================*/
create table natureza_operacao (
   cdnatoperacao        int                  identity,
   dsnatoperacao        varchar(30)          null,
   tributavel           bit                  null,
   txresultado          bit                  null,
   ativo                bit                  null,
   constraint pk_natureza_operacao primary key nonclustered (cdnatoperacao)
)
go

/*==============================================================*/
/* Table: nota_despesa                                          */
/*==============================================================*/
create table nota_despesa (
   cdnotadespesa        int                  identity,
   cdatendimento        int                  null,
   cdconducao           int                  null,
   cdhospedagem         int                  null,
   dtemissaond          datetime             null,
   stnotadespesa        char(1)              null,
   versao               int                  null,
   ativo                bit                  null,
   constraint pk_nota_despesa primary key nonclustered (cdnotadespesa)
)
go

/*==============================================================*/
/* Index: conducao__nota_despesa_fk                             */
/*==============================================================*/
create index conducao__nota_despesa_fk on nota_despesa (
cdconducao asc
)
go

/*==============================================================*/
/* Index: hospedagem__nota_despesa_fk                           */
/*==============================================================*/
create index hospedagem__nota_despesa_fk on nota_despesa (
cdhospedagem asc
)
go

/*==============================================================*/
/* Index: atendimento_nota_despesa_fk                           */
/*==============================================================*/
create index atendimento_nota_despesa_fk on nota_despesa (
cdatendimento asc
)
go

/*==============================================================*/
/* Table: nota_fiscal                                           */
/*==============================================================*/
create table nota_fiscal (
   nrnotafiscal         int                  identity,
   cdvenda              int                  not null,
   vlrbaseicms          money                null,
   vlricms              money                null,
   vlrbaseiss           money                null,
   vlriss               money                null,
   vlrtotprodnotafiscal money                null,
   vlrtotservnotafiscal money                null,
   prccotaicms          money                null,
   prccotaiss           money                null,
   constraint pk_nota_fiscal primary key (nrnotafiscal)
)
go

/*==============================================================*/
/* Index: venda__nota_fiscal_fk                                 */
/*==============================================================*/
create index venda__nota_fiscal_fk on nota_fiscal (
cdvenda asc
)
go

/*==============================================================*/
/* Table: ocorrencia_cheque                                     */
/*==============================================================*/
create table ocorrencia_cheque (
   nrocorrencia         int                  identity,
   cdchequerecebido     int                  not null,
   dtregistro           datetime             null,
   dsocorrencia         varchar(60)          null,
   constraint pk_ocorrencia_cheque primary key nonclustered (nrocorrencia)
)
go

/*==============================================================*/
/* Index: cheque_recebido__ocorrencia_cheque_fk                 */
/*==============================================================*/
create index cheque_recebido__ocorrencia_cheque_fk on ocorrencia_cheque (
cdchequerecebido asc
)
go

/*==============================================================*/
/* Table: parcela_pagar                                         */
/*==============================================================*/
create table parcela_pagar (
   cdparcelapagar       int                  identity,
   cdcontacorrente      int                  not null,
   cdesppagamento       int                  not null,
   cdcontapagar         int                  not null,
   nrparcelapagar       smallint             null,
   dtemissaoparcpagar   datetime             null,
   dtvencparcpagar      datetime             null,
   vlrparcpagar         money                null,
   prcmultaparcpagar    money                null,
   vlrparcpago          money                null,
   dtpgtoparcpagar      datetime             null,
   stparcpagar          char(1)              null,
   dshistparcpagar      varchar(60)          null,
   ativo                bit                  null,
   constraint pk_parcela_pagar primary key nonclustered (cdparcelapagar)
)
go

/*==============================================================*/
/* Index: contas_pagar__parcela_pagar_fk                        */
/*==============================================================*/
create index contas_pagar__parcela_pagar_fk on parcela_pagar (
cdcontapagar asc
)
go

/*==============================================================*/
/* Index: esp_pagamento__parcela_pagar_fk                       */
/*==============================================================*/
create index esp_pagamento__parcela_pagar_fk on parcela_pagar (
cdesppagamento asc
)
go

/*==============================================================*/
/* Index: cta_corrente__parcela_pagar_fk                        */
/*==============================================================*/
create index cta_corrente__parcela_pagar_fk on parcela_pagar (
cdcontacorrente asc
)
go

/*==============================================================*/
/* Table: parcela_receber                                       */
/*==============================================================*/
create table parcela_receber (
   cdparcelareceber     int                  identity,
   cdcontareceber       int                  not null,
   cdesppagamento       int                  not null,
   cdcontacorrente      int                  not null,
   nrparcelareceber     smallint             null,
   dtemissaoparcreceber datetime             null,
   dtvencparcreceber    datetime             null,
   vlrparcreceber       money                null,
   prcmultaparcreceber  money                null,
   vlrparcrecebido      money                null,
   dtrctoparcreceber_   datetime             null,
   stparcreceber        char(1)              null,
   dshistparcreceber    varchar(60)          null,
   nrcartaocredito      numeric(15)          null,
   dtvalcartaocredito   datetime             null,
   ativo                bit                  null,
   constraint pk_parcela_receber primary key nonclustered (cdparcelareceber)
)
go

/*==============================================================*/
/* Index: contas_receber__parcela_receber_fk                    */
/*==============================================================*/
create index contas_receber__parcela_receber_fk on parcela_receber (
cdcontareceber asc
)
go

/*==============================================================*/
/* Index: conta_corrente__parcela_receber_fk                    */
/*==============================================================*/
create index conta_corrente__parcela_receber_fk on parcela_receber (
cdcontacorrente asc
)
go

/*==============================================================*/
/* Index: especie_pagamento__parcela_receber_fk                 */
/*==============================================================*/
create index especie_pagamento__parcela_receber_fk on parcela_receber (
cdesppagamento asc
)
go

/*==============================================================*/
/* Table: pelagem                                               */
/*==============================================================*/
create table pelagem (
   cdpelagem            int                  identity,
   nmpelagem            varchar(30)          null,
   ativo                bit                  null,
   constraint pk_pelagem primary key nonclustered (cdpelagem)
)
go

/*==============================================================*/
/* Table: pendencia                                             */
/*==============================================================*/
create table pendencia (
   nrpendencia          int                  identity,
   cdanimal             int                  not null,
   dtpendencia          datetime             null,
   txpendencia          varchar(60)          null,
   ativo                bit                  null,
   constraint pk_pendencia primary key nonclustered (nrpendencia)
)
go

/*==============================================================*/
/* Index: animal__pendencia_fk                                  */
/*==============================================================*/
create index animal__pendencia_fk on pendencia (
cdanimal asc
)
go

/*==============================================================*/
/* Table: perfil                                                */
/*==============================================================*/
create table perfil (
   cdperfil             int                  identity,
   dsperfil             varchar(40)          null,
   ativo                bit                  null,
   constraint pk_perfil primary key nonclustered (cdperfil)
)
go

/*==============================================================*/
/* Table: pertence                                              */
/*==============================================================*/
create table pertence (
   nrpertence           int                  identity,
   cdhospede            int                  null,
   dspertence           varchar(30)          null,
   txobspertence        varchar(60)          null,
   ativo                bit                  null,
   constraint pk_pertence primary key nonclustered (nrpertence)
)
go

/*==============================================================*/
/* Index: hospede__pertence_fk                                  */
/*==============================================================*/
create index hospede__pertence_fk on pertence (
cdhospede asc
)
go

/*==============================================================*/
/* Table: pesagem                                               */
/*==============================================================*/
create table pesagem (
   nrpesagem            int                  identity,
   cdanimal             int                  not null,
   dtpesagem            datetime             null,
   peso                 money                null,
   ativo                bit                  null,
   constraint pk_pesagem primary key nonclustered (nrpesagem)
)
go

/*==============================================================*/
/* Index: animal__pesagem_fk                                    */
/*==============================================================*/
create index animal__pesagem_fk on pesagem (
cdanimal asc
)
go

/*==============================================================*/
/* Table: porte                                                 */
/*==============================================================*/
create table porte (
   cdporte              int                  identity,
   dsporte              varchar(30)          null,
   ativo                bit                  null,
   constraint pk_porte primary key nonclustered (cdporte)
)
go

/*==============================================================*/
/* Table: produto                                               */
/*==============================================================*/
create table produto (
   cdproduto            int                  not null,
   cdgrupoproduto       int                  not null,
   cdfornecedor         int                  not null,
   cdunidmedida         int                  not null,
   dsproduto            varchar(60)          null,
   dsetiqueta           varchar(30)          null,
   qtdatual             int                  null,
   qtdminima            int                  null,
   qtdmaxima            int                  null,
   vlrcusto             money                null,
   vlrcustomedio        money                null,
   vlrcustooper         money                null,
   vlrcustofrete        money                null,
   prcmargemlucro       money                null,
   prccomissao          money                null,
   vlrpromocao          money                null,
   prcdesconto          money                null,
   vlrdesconto          money                null,
   vlrvenda             money                null,
   vlrcreditoicms       money                null,
   vlrdebitoicms        money                null,
   versao               int                  null,
   ativo                bit                  null,
   constraint pk_produto primary key nonclustered (cdproduto)
)
go

/*==============================================================*/
/* Index: grupo_produto__produto_fk                             */
/*==============================================================*/
create index grupo_produto__produto_fk on produto (
cdgrupoproduto asc
)
go

/*==============================================================*/
/* Index: fornecedor_produto_fk                                 */
/*==============================================================*/
create index fornecedor_produto_fk on produto (
cdfornecedor asc
)
go

/*==============================================================*/
/* Index: unidade_medida__produto_fk                            */
/*==============================================================*/
create index unidade_medida__produto_fk on produto (
cdunidmedida asc
)
go

/*==============================================================*/
/* Table: raca                                                  */
/*==============================================================*/
create table raca (
   cdraca               int                  identity,
   cdporte              int                  not null,
   cdespecie            int                  not null,
   nmraca               varchar(30)          null,
   ativo                bit                  null,
   constraint pk_raca primary key nonclustered (cdraca)
)
go

/*==============================================================*/
/* Index: especie__raca_fk                                      */
/*==============================================================*/
create index especie__raca_fk on raca (
cdespecie asc
)
go

/*==============================================================*/
/* Index: porte__raca_fk                                        */
/*==============================================================*/
create index porte__raca_fk on raca (
cdporte asc
)
go

/*==============================================================*/
/* Table: receita                                               */
/*==============================================================*/
create table receita (
   nrreceita            int                  identity,
   cdanimal             int                  not null,
   dtreceita            datetime             null,
   txprescricao         varchar(512)         null,
   ativo                bit                  null,
   constraint pk_receita primary key nonclustered (nrreceita)
)
go

/*==============================================================*/
/* Index: animal__receita_fk                                    */
/*==============================================================*/
create index animal__receita_fk on receita (
cdanimal asc
)
go

/*==============================================================*/
/* Table: recomendacao                                          */
/*==============================================================*/
create table recomendacao (
   nrrecomendacao       int                  identity,
   cdhospede            int                  not null,
   dtrecomendacao       datetime             null,
   txrecomendacao       varchar(256)         null,
   ativo                bit                  null,
   constraint pk_recomendacao primary key nonclustered (nrrecomendacao)
)
go

/*==============================================================*/
/* Index: hosp__recomendacao_fk                                 */
/*==============================================================*/
create index hosp__recomendacao_fk on recomendacao (
cdhospede asc
)
go

/*==============================================================*/
/* Table: servico                                               */
/*==============================================================*/
create table servico (
   cdservico            int                  identity,
   cdunidmedida         int                  not null,
   dsservico            varchar(40)          null,
   vlrunitservico       money                null,
   vlrpromocao          money                null,
   prcdescontoservico   money                null,
   prccomissaoservico   money                null,
   ativo                bit                  null,
   constraint pk_servico primary key nonclustered (cdservico)
)
go

/*==============================================================*/
/* Index: unidade_medida__servico_fk                            */
/*==============================================================*/
create index unidade_medida__servico_fk on servico (
cdunidmedida asc
)
go

/*==============================================================*/
/* Table: telefone                                              */
/*==============================================================*/
create table telefone (
   cdtelefone           int                  identity,
   cdtipotelefone       int                  not null,
   ddd                  varchar(2)           null,
   nrtelefone           varchar(8)           null,
   ativo                bit                  null,
   constraint pk_telefone primary key nonclustered (cdtelefone)
)
go

/*==============================================================*/
/* Index: tipo_telefone__telefone_fk                            */
/*==============================================================*/
create index tipo_telefone__telefone_fk on telefone (
cdtipotelefone asc
)
go

/*==============================================================*/
/* Table: tipo_acesso                                           */
/*==============================================================*/
create table tipo_acesso (
   cdtipoacesso         int                  identity,
   dstipoacesso         varchar(40)          null,
   ativo                bit                  null,
   constraint pk_tipo_acesso primary key nonclustered (cdtipoacesso)
)
go

/*==============================================================*/
/* Table: tipo_atendimento                                      */
/*==============================================================*/
create table tipo_atendimento (
   cdtipoatdmto         int                  identity,
   dstipoatdmto         varchar(40)          null,
   ativo                bit                  null,
   constraint pk_tipo_atendimento primary key nonclustered (cdtipoatdmto)
)
go

/*==============================================================*/
/* Table: tipo_endereco                                         */
/*==============================================================*/
create table tipo_endereco (
   cdtipoendereco       int                  identity,
   dstipoendereco       varchar(30)          null,
   ativo                bit                  null,
   constraint pk_tipo_endereco primary key nonclustered (cdtipoendereco)
)
go

/*==============================================================*/
/* Table: tipo_telefone                                         */
/*==============================================================*/
create table tipo_telefone (
   cdtipotelefone       int                  identity,
   dstipotelefone       varchar(30)          null,
   ativo                bit                  null,
   constraint pk_tipo_telefone primary key nonclustered (cdtipotelefone)
)
go

/*==============================================================*/
/* Table: uf                                                    */
/*==============================================================*/
create table uf (
   cduf                 smallint             identity,
   uf                   varchar(2)           null,
   nmestado             varchar(30)          null,
   nmpais               varchar(20)          null,
   prccotaicms          money                null,
   prccotaiss           money                null,
   ativo                bit                  null,
   constraint pk_uf primary key nonclustered (cduf)
)
go

/*==============================================================*/
/* Table: unidade_medida                                        */
/*==============================================================*/
create table unidade_medida (
   cdunidmedida         int                  identity,
   dsunidmedida         varchar(15)          null,
   abrvunidmedida       varchar(6)           null,
   ativo                bit                  null,
   constraint pk_unidade_medida primary key nonclustered (cdunidmedida)
)
go

/*==============================================================*/
/* Table: usuario                                               */
/*==============================================================*/
create table usuario (
   cdusuario            int                  identity,
   cdperfil             int                  not null,
   dsusuario            varchar(20)          null,
   login                varchar(15)          null,
   senha                varchar(50)          null,
   dtexpiracaosenha     datetime             null,
   dthrlogonatual       datetime             null,
   dthrultimologon      datetime             null,
   ativo                bit                  null,
   constraint pk_usuario primary key nonclustered (cdusuario)
)
go

/*==============================================================*/
/* Index: perfil__usuario_fk                                    */
/*==============================================================*/
create index perfil__usuario_fk on usuario (
cdperfil asc
)
go

/*==============================================================*/
/* Table: vacina                                                */
/*==============================================================*/
create table vacina (
   cdvacina             int                  identity,
   dsvacina             varchar(40)          null,
   qtddiasrevacinacao   smallint             null,
   nrdoses              smallint             null,
   ativo                bit                  null,
   constraint pk_vacina primary key nonclustered (cdvacina)
)
go

/*==============================================================*/
/* Table: venda                                                 */
/*==============================================================*/
create table venda (
   cdvenda              int                  identity,
   cdcliente            int                  not null,
   cdnotadespesa        int                  null,
   cdfuncionario        int                  not null,
   cdnatoperacao        int                  not null,
   dtvenda              datetime             null,
   modopgto             char(1)              null,
   txobservacao         varchar(60)          null,
   versao               int                  null,
   ativo                bit                  null,
   constraint pk_venda primary key nonclustered (cdvenda)
)
go

/*==============================================================*/
/* Index: natureza_operacao__venda_fk                           */
/*==============================================================*/
create index natureza_operacao__venda_fk on venda (
cdnatoperacao asc
)
go

/*==============================================================*/
/* Index: nota_despesa__venda_fk                                */
/*==============================================================*/
create index nota_despesa__venda_fk on venda (
cdnotadespesa asc
)
go

/*==============================================================*/
/* Index: funcionario__venda_fk                                 */
/*==============================================================*/
create index funcionario__venda_fk on venda (
cdfuncionario asc
)
go

/*==============================================================*/
/* Index: cliente__venda_fk                                     */
/*==============================================================*/
create index cliente__venda_fk on venda (
cdcliente asc
)
go

/*==============================================================*/
/* Table: vermifugo                                             */
/*==============================================================*/
create table vermifugo (
   cdvermifugo          int                  identity,
   dsvermifugo          varchar(40)          null,
   ativo                bit                  null,
   constraint pk_vermifugo primary key nonclustered (cdvermifugo)
)
go

alter table acesso
   add constraint fk_acesso_funcao__a_funcao foreign key (cdfuncao)
      references funcao (cdfuncao)
go

alter table acesso
   add constraint fk_acesso_perfil__a_perfil foreign key (cdperfil)
      references perfil (cdperfil)
go

alter table acesso
   add constraint fk_acesso_tipo_aces_tipo_ace foreign key (cdtipoacesso)
      references tipo_acesso (cdtipoacesso)
go

alter table anamnese
   add constraint fk_anamnese_animal__a_animal foreign key (cdanimal)
      references animal (cdanimal)
go

alter table animal
   add constraint fk_animal_cliente___cliente foreign key (cdcliente)
      references cliente (cdcliente)
go

alter table animal
   add constraint fk_animal_pelagem___pelagem foreign key (cdpelagem)
      references pelagem (cdpelagem)
go

alter table animal
   add constraint fk_animal_raca__ani_raca foreign key (cdraca)
      references raca (cdraca)
go

alter table animal_transportado
   add constraint fk_animal_t_animal__a_animal foreign key (cdanimal)
      references animal (cdanimal)
go

alter table animal_transportado
   add constraint fk_animal_t_conducao__conducao foreign key (cdconducao)
      references conducao (cdconducao)
go

alter table animal_transportado
   add constraint fk_animal_t_itinerari_itinerar foreign key (cditinerario)
      references itinerario (cditinerario)
go

alter table atendimento
   add constraint fk_atendime_animal__a_animal foreign key (cdanimal)
      references animal (cdanimal)
go

alter table atendimento
   add constraint fk_atendime_cliente___cliente foreign key (cdcliente)
      references cliente (cdcliente)
go

alter table atendimento
   add constraint fk_atendime_funcionar_funciona foreign key (cdfuncionario)
      references funcionario (cdfuncionario)
go

alter table atendimento
   add constraint fk_atendime_tipo_aten_tipo_ate foreign key (cdtipoatdmto)
      references tipo_atendimento (cdtipoatdmto)
go

alter table carteira_vacina
   add constraint fk_carteira_animal__c_animal foreign key (cdanimal)
      references animal (cdanimal)
go

alter table carteira_vacina
   add constraint fk_carteira_vacina__c_vacina foreign key (cdvacina)
      references vacina (cdvacina)
go

alter table carteira_vermifugo
   add constraint fk_carteira_animal_ca_animal foreign key (cdanimal)
      references animal (cdanimal)
go

alter table carteira_vermifugo
   add constraint fk_carteira_vermifugo_vermifug foreign key (cdvermifugo)
      references vermifugo (cdvermifugo)
go

alter table cheque_recebido
   add constraint fk_cheque_r_parcela_r_parcela_ foreign key (cdparcelareceber)
      references parcela_receber (cdparcelareceber)
go

alter table cliente
   add constraint fk_cliente_atividade_atividad foreign key (cdativprofissional)
      references atividade_profissional (cdativprofissional)
go

alter table cliente
   add constraint fk_cliente_uf_local__uf foreign key (cduf)
      references uf (cduf)
go

alter table cliente_endereco
   add constraint fk_cliente__cliente_c_cliente foreign key (cdcliente)
      references cliente (cdcliente)
go

alter table cliente_endereco
   add constraint fk_cliente__endereco__endereco foreign key (cdendereco)
      references endereco (cdendereco)
go

alter table cliente_telefone
   add constraint fk_cliente__cliente___cliente foreign key (cdcliente)
      references cliente (cdcliente)
go

alter table cliente_telefone
   add constraint fk_cliente__telefone__telefone foreign key (cdtelefone)
      references telefone (cdtelefone)
go

alter table compra
   add constraint fk_compra_fornecedo_forneced foreign key (cdfornecedor)
      references fornecedor (cdfornecedor)
go

alter table compra
   add constraint fk_compra_funcionar_funciona foreign key (cdfuncionario)
      references funcionario (cdfuncionario)
go

alter table compra
   add constraint fk_compra_natureza__natureza foreign key (cdnatoperacao)
      references natureza_operacao (cdnatoperacao)
go

alter table conducao
   add constraint fk_conducao_cliente___cliente foreign key (cdcliente)
      references cliente (cdcliente)
go

alter table conducao
   add constraint fk_conducao_funcionar_funciona foreign key (cdfuncionario)
      references funcionario (cdfuncionario)
go

alter table contas_pagar
   add constraint fk_contas_p_compra__c_compra foreign key (cdcompra)
      references compra (cdcompra)
go

alter table contas_pagar
   add constraint fk_contas_p_conta_con_conta_co foreign key (cdcontacontabil)
      references conta_contabil (cdcontacontabil)
go

alter table contas_pagar
   add constraint fk_contas_p_fornecedo_forneced foreign key (cdfornecedor)
      references fornecedor (cdfornecedor)
go

alter table contas_receber
   add constraint fk_contas_r_cliente___cliente foreign key (cdcliente)
      references cliente (cdcliente)
go

alter table contas_receber
   add constraint fk_contas_r_conta_con_conta_co foreign key (cdcontacontabil)
      references conta_contabil (cdcontacontabil)
go

alter table contas_receber
   add constraint fk_contas_r_venda__co_venda foreign key (cdvenda)
      references venda (cdvenda)
go

alter table diaria_hospedagem
   add constraint fk_diaria_h_porte__di_porte foreign key (cdporte)
      references porte (cdporte)
go

alter table empresa_endereco
   add constraint fk_empresa__empresa_endereco foreign key (cdempresa)
      references empresa (cdempresa)
go

alter table empresa_endereco
   add constraint fk_empresa__endereco__endereco foreign key (cdendereco)
      references endereco (cdendereco)
go

alter table empresa_telefone
   add constraint fk_empresa__empresa_e_empresa foreign key (cdempresa)
      references empresa (cdempresa)
go

alter table empresa_telefone
   add constraint fk_empresa__telefone__telefone foreign key (cdtelefone)
      references telefone (cdtelefone)
go

alter table endereco
   add constraint fk_endereco_tipo_ende_tipo_end foreign key (cdtipoendereco)
      references tipo_endereco (cdtipoendereco)
go

alter table endereco
   add constraint fk_endereco_uf__ender_uf foreign key (cduf)
      references uf (cduf)
go

alter table exame_solicitado
   add constraint fk_exame_so_relations_animal foreign key (cdanimal)
      references animal (cdanimal)
go

alter table exame_solicitado
   add constraint fk_exame_so_relations_exame foreign key (cdexame)
      references exame (cdexame)
go

alter table fornecedor_endereco
   add constraint fk_forneced_endereco__endereco foreign key (cdendereco)
      references endereco (cdendereco)
go

alter table fornecedor_endereco
   add constraint fk_forneced_fornecedo_forneced foreign key (cdfornecedor)
      references fornecedor (cdfornecedor)
go

alter table fornecedor_telefone
   add constraint fk_forneced_fornecedo_telefone foreign key (cdfornecedor)
      references fornecedor (cdfornecedor)
go

alter table fornecedor_telefone
   add constraint fk_forneced_telefone__telefone foreign key (cdtelefone)
      references telefone (cdtelefone)
go

alter table funcionario
   add constraint fk_funciona_agenda__f_agenda foreign key (cdagenda)
      references agenda (cdagenda)
go

alter table funcionario
   add constraint fk_funciona_atividade_atividad foreign key (cdativprofissional)
      references atividade_profissional (cdativprofissional)
go

alter table funcionario
   add constraint fk_funciona_cargo__fu_cargo foreign key (cdcargo)
      references cargo (cdcargo)
go

alter table funcionario
   add constraint fk_funciona_uf_expedi_uf foreign key (cduf)
      references uf (cduf)
go

alter table funcionario
   add constraint fk_funciona_usuario___usuario foreign key (cdusuario)
      references usuario (cdusuario)
go

alter table funcionario_endereco
   add constraint fk_funciona_endereco__endereco foreign key (cdendereco)
      references endereco (cdendereco)
go

alter table funcionario_endereco
   add constraint fk_funciona_funcionar_end foreign key (cdfuncionario)
      references funcionario (cdfuncionario)
go

alter table funcionario_telefone
   add constraint fk_funciona_funcionar_funciona foreign key (cdfuncionario)
      references funcionario (cdfuncionario)
go

alter table funcionario_telefone
   add constraint fk_funciona_telefone_telefone foreign key (cdtelefone)
      references telefone (cdtelefone)
go

alter table historico_senha
   add constraint fk_historic_usuario___usuario foreign key (cdusuario)
      references usuario (cdusuario)
go

alter table hospedagem
   add constraint fk_hospedag_baia_hosp_baia foreign key (cdbaia)
      references baia (cdbaia)
go

alter table hospedagem
   add constraint fk_hospedag_cliente___cliente foreign key (cdcliente)
      references cliente (cdcliente)
go

alter table hospedagem
   add constraint fk_hospedag_funcionar_funciona foreign key (cdfuncionario)
      references funcionario (cdfuncionario)
go

alter table hospede
   add constraint fk_hospede_animal__h_animal foreign key (cdanimal)
      references animal (cdanimal)
go

alter table hospede
   add constraint fk_hospede_diaria_ho_diaria_h foreign key (cddiariahosp)
      references diaria_hospedagem (cddiariahosp)
go

alter table hospede
   add constraint fk_hospede_hospedage_hospedag foreign key (cdhospedagem)
      references hospedagem (cdhospedagem)
go

alter table item_compra
   add constraint fk_item_com_compra__i_compra foreign key (cdcompra)
      references compra (cdcompra)
go

alter table item_compra
   add constraint fk_item_com_produto___produto foreign key (cdproduto)
      references produto (cdproduto)
go

alter table item_produto_nd
   add constraint fk_item_pro_nota_desp_nota_des foreign key (cdnotadespesa)
      references nota_despesa (cdnotadespesa)
go

alter table item_produto_nd
   add constraint fk_item_pro_produto___produto foreign key (cdproduto)
      references produto (cdproduto)
go

alter table item_produto_nf
   add constraint fk_item_pro_nota_fisc_nota_fis foreign key (nrnotafiscal)
      references nota_fiscal (nrnotafiscal)
go

alter table item_produto_nf
   add constraint fk_item_pro_relations_produto foreign key (cdproduto)
      references produto (cdproduto)
go

alter table item_servico_nd
   add constraint fk_item_ser_nota_desp_nota_des foreign key (cdnotadespesa)
      references nota_despesa (cdnotadespesa)
go

alter table item_servico_nd
   add constraint fk_item_servico_nd___servico foreign key (cdservico)
      references servico (cdservico)
go

alter table item_servico_nf
   add constraint fk_item_ser_notafisca_nota_fis foreign key (nrnotafiscal)
      references nota_fiscal (nrnotafiscal)
go

alter table item_servico_nf
   add constraint fk_item_ser_servico___servico foreign key (cdservico)
      references servico (cdservico)
go

alter table lancamento_financeiro
   add constraint fk_lancamen_parcela_p_parcela_ foreign key (cdparcelapagar)
      references parcela_pagar (cdparcelapagar)
go

alter table lancamento_financeiro
   add constraint fk_lancamen_parcela_r_parcela_ foreign key (cdparcelareceber)
      references parcela_receber (cdparcelareceber)
go

alter table nota_despesa
   add constraint fk_nota_des_atendimen_atendime foreign key (cdatendimento)
      references atendimento (cdatendimento)
go

alter table nota_despesa
   add constraint fk_nota_des_conducao__conducao foreign key (cdconducao)
      references conducao (cdconducao)
go

alter table nota_despesa
   add constraint fk_nota_des_hospedage_hospedag foreign key (cdhospedagem)
      references hospedagem (cdhospedagem)
go

alter table nota_fiscal
   add constraint fk_nota_fis_venda__no_venda foreign key (cdvenda)
      references venda (cdvenda)
go

alter table ocorrencia_cheque
   add constraint fk_ocorrenc_cheque_re_cheque_r foreign key (cdchequerecebido)
      references cheque_recebido (cdchequerecebido)
go

alter table parcela_pagar
   add constraint fk_parcela__contas_pa_contas_p foreign key (cdcontapagar)
      references contas_pagar (cdcontapagar)
go

alter table parcela_pagar
   add constraint fk_parcela__cta_corre_conta_co foreign key (cdcontacorrente)
      references conta_corrente (cdcontacorrente)
go

alter table parcela_pagar
   add constraint fk_parcela__esp_pagam_especie_ foreign key (cdesppagamento)
      references especie_pagamento (cdesppagamento)
go

alter table parcela_receber
   add constraint fk_parcela__contas_re_contas_r foreign key (cdcontareceber)
      references contas_receber (cdcontareceber)
go

alter table parcela_receber
   add constraint fk_parcela__conta_cor_conta_co foreign key (cdcontacorrente)
      references conta_corrente (cdcontacorrente)
go

alter table parcela_receber
   add constraint fk_parcela__especie_p_especie_ foreign key (cdesppagamento)
      references especie_pagamento (cdesppagamento)
go

alter table pendencia
   add constraint fk_pendenci_animal__p_animal foreign key (cdanimal)
      references animal (cdanimal)
go

alter table pertence
   add constraint fk_pertence_hospede___hospede foreign key (cdhospede)
      references hospede (cdhospede)
go

alter table pesagem
   add constraint fk_pesagem_animal__p_animal foreign key (cdanimal)
      references animal (cdanimal)
go

alter table produto
   add constraint fk_produto_fornecedo_forneced foreign key (cdfornecedor)
      references fornecedor (cdfornecedor)
go

alter table produto
   add constraint fk_produto_grupo_pro_grupo_pr foreign key (cdgrupoproduto)
      references grupo_produto (cdgrupoproduto)
go

alter table produto
   add constraint fk_produto_unidade_m_unidade_ foreign key (cdunidmedida)
      references unidade_medida (cdunidmedida)
go

alter table raca
   add constraint fk_raca_especie___especie foreign key (cdespecie)
      references especie (cdespecie)
go

alter table raca
   add constraint fk_raca_porte__ra_porte foreign key (cdporte)
      references porte (cdporte)
go

alter table receita
   add constraint fk_receita_animal__r_animal foreign key (cdanimal)
      references animal (cdanimal)
go

alter table recomendacao
   add constraint fk_recomend_hosp__rec_hospede foreign key (cdhospede)
      references hospede (cdhospede)
go

alter table servico
   add constraint fk_servico_unidade_m_unidade_ foreign key (cdunidmedida)
      references unidade_medida (cdunidmedida)
go

alter table telefone
   add constraint fk_telefone_tipo_tele_tipo_tel foreign key (cdtipotelefone)
      references tipo_telefone (cdtipotelefone)
go

alter table usuario
   add constraint fk_usuario_perfil__u_perfil foreign key (cdperfil)
      references perfil (cdperfil)
go

alter table venda
   add constraint fk_venda_cliente___cliente foreign key (cdcliente)
      references cliente (cdcliente)
go

alter table venda
   add constraint fk_venda_funcionar_funciona foreign key (cdfuncionario)
      references funcionario (cdfuncionario)
go

alter table venda
   add constraint fk_venda_natureza__natureza foreign key (cdnatoperacao)
      references natureza_operacao (cdnatoperacao)
go

alter table venda
   add constraint fk_venda_nota_desp_nota_des foreign key (cdnotadespesa)
      references nota_despesa (cdnotadespesa)
go

